function [x,y,z] = sPlotSurf(sM, x1,y1,z1) % sPlotSurf - plots a surface in cartesian coordinate system % from spline matrix in spherical coordinates % [x,y,z] = sPlotSurf(sM, x1,y1,z1) % sM - spline coeffitients matrix, can be obtained from % the function sFitCart % x1,y1,z1 - optional cartesian coordinates displayed in the % figure(2) by surf(x1,y1,z1) % x,y,z - mesh matrices that can be used with 'surf' % [x,y,z] = sPlotSurf(sM); % surf(x,y,z); % Without output parameters, sPlotSurf plots the surface % % see also: sFitCart, sFit, sMBA sM = sExtend(sValueM(sM),[0 1],[0 0]); [m,n] = size(sM); fi = (((1:m)-1)/(m-1)*2*pi-pi)' * ones(1,n); teta= ones(m,1) * (((1:n)-1)/(n-1)*pi-pi/2); x = sM.*cos(teta).*cos(fi); y = sM.*cos(teta).*sin(fi); z = sM.*sin(teta); fig = gcf; if nargout == 0, figure(fig); surf(x,y,z); if nargin == 4, hold on; plot3(x1,y1,z1,'o'); hold off; end; end; return;