Clear Filters
Clear Filters

surface plot for multiple vector points

3 views (last 30 days)
Ashbub
Ashbub on 22 Jan 2018
Commented: Ashbub on 22 Jan 2018
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

Accepted Answer

KSSV
KSSV on 22 Jan 2018
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
  1 Comment
Ashbub
Ashbub on 22 Jan 2018
Thankyou so much!! Here how it looks like. Beautiful, isn't it?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!