필터 지우기
필터 지우기

surface plot for multiple vector points

조회 수: 3 (최근 30일)
Ashbub
Ashbub 2018년 1월 22일
댓글: Ashbub 2018년 1월 22일
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

채택된 답변

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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by