% Farouki data % 6-20-96 svd3dfars.m % modification of bana3dn_herm.m m1 = 6 n1 = 3 % number of data points in each direction: rows, columns far=[-3.0 -1.2 0.0 -3.0 0.0 0.1 -2.7 1.3 -0.1 -2.0 -1.0 -0.2 -1.7 0.2 0.3 -1.5 1.6 0.0 -1.1 -1.5 1.0 -0.6 -0.1 1.1 -0.8 1.2 0.3 -0.4 -0.8 -0.3 0.0 0.1 0.1 0.2 1.0 0.5 0.8 -1.0 0.3 1.5 -0.3 0.4 2.2 1.5 0.6 2.3 -1.7 0.2 3.0 -0.1 0.3 3.3 1.2 0.5 ]; ax = far(:,1);ay = far(:,2);az = far(:,3); axx=reshape(ax,n1,m1)'; ayy=reshape(ay,n1,m1)'; azz=reshape(az,n1,m1)'; %number of rows & columns in surface representation: k=5; n11=k*(n1-1)+1; m11=k*(m1-1)+1; xx=linspace(1,n1,n1)';yy=linspace(1,m1,m1)'; xxx=linspace(1,n1,n11)';yyy=linspace(1,m1,m11)'; [u,s,v]=svd(axx); s = diag(s); z = zeros(m11,n11); for j=1:3 spx = spline(xx,v(:,j), xxx); spy = spline(yy,u(:,j), yyy); z = z + s(j)*spy*spx'; end splx=z; [u,s,v]=svd(ayy); s = diag(s); z = zeros(m11,n11); for j=1:3 spx = spline(xx,v(:,j), xxx); spy = spline(yy,u(:,j), yyy); z = z + s(j)*spy*spx'; end sply=z; [u,s,v]=svd(azz); s = diag(s); z = zeros(m11,n11); for j=1:3 spx = spline(xx,v(:,j), xxx); spy = spline(yy,u(:,j), yyy); z = z + s(j)*spy*spx'; end splz=z; subplot(1,1,1) plot3(axx,ayy,azz,'o') subplot(1,2,1) view(50,20) subplot(1,2,2) view(45,20) clf subplot(2,2,1) surf(splx,sply,splz,splz) subplot(2,2,2) view(45,20) subplot(2,2,3) view(135,20) subplot(2,2,4) view(130,20)