MATLAB: Surface plot for multiple vector points

scatter3surface plotvectors

Hi from the following code, I am getting the 3D scatter plot for multiple vector points(attached are the same plot from different view angle). F1111, F1122 etc. are coefficients calculated from the vectors. I need to plot surface instead. But could not work it out using surf. Please suggest.
Thanks.
for th=0:.1:2*pi
for fi=0:0.1:pi
fn4= 1/(4*pi)*(F1111*(cos(th)*sin(th))^4 + F1122 *(cos(th)*cos(fi))^2*(sin(th)*cos(fi))^2+...........continues.......)
[X,Y,Z] = sph2cart(th,fi,fn4);
scatter3(X,Y,Z,'.r');
hold on;
end
end

Best Answer

clc; clear all ;
th=0:.1:2*pi ;
fi=0:0.1:pi ;
XX = zeros(length(th),length(fi)) ;
YY = zeros(length(th),length(fi)) ;
ZZ = zeros(length(th),length(fi)) ;
for i = 1:length(th)
for j = 1:length(fi)
fn4= 1/(4*pi)*(F1111*(cos(th(i))*sin(th(i)))^4 + F1122 *(cos(th(i))*cos(fi(j)))^2*(sin(th(i))*cos(fi(j)))^2 +...........continues.......)
[X,Y,Z] = sph2cart(th(i),fi(j),fn4);
scatter3(X,Y,Z,'.r');
hold on;
XX(i,j) = X ; YY(i,j) = Y ; ZZ(i,j) = Z ;
end
end
Now use surf on XX,YY and ZZ