フィルターのクリア

Shaded surface

7 ビュー (過去 30 日間)
Ben
Ben 2011 年 11 月 16 日
Hi
I have 3 Arrays with values of which i am doing a 3D plot. Currently i am using "plot3()". I would rather like to have a shaded surface...
x(i)=[cos(psi)*cos(phi)*r];
y(i)=[cos(psi)*sin(phi)*r];
z(i)=[sin(psi)*r];
plot3(x,y,z)
Any Hints?

採用された回答

Grzegorz Knor
Grzegorz Knor 2011 年 11 月 16 日
St11=100;
Sc11=St11*2/3;
St22=80;
Sc22=St22*2/3;
S=60;
i1 = 0;
r = NaN(101,51);
for phi=0:pi/50:2*pi
i1 = i1+1;
i2 = 0;
if cos(phi)>=0
X=St11;
else
X=Sc11;
end
if sin(phi)>=0
Y=St22;
else
Y=Sc22;
end
for psi=-pi/2:pi/50:pi/2
i2=i2+1;
F=@(r0)(((cos(phi)*cos(psi)*r0)/X)^2-(cos(phi)*cos(psi)*r0*sin(phi)*cos(psi)*r0)/(X^2)+((sin(phi)*cos(psi)*r0)/Y)^2+(r0*sin(psi)/S)^2-1)^2;
r(i1,i2)=abs(fminsearch(F,0));
end
end
[psi,phi] = meshgrid(-pi/2:pi/50:pi/2,0:pi/50:2*pi);
x=cos(psi).*cos(phi).*r;
y=cos(psi).*sin(phi).*r;
z=sin(psi).*r;
surf(x,y,z)

その他の回答 (2 件)

Grzegorz Knor
Grzegorz Knor 2011 年 11 月 16 日
[psi phi] = meshgrid(0:0.05:2*pi);
r = 1;
x=cos(psi).*cos(phi).*r;
y=cos(psi).*sin(phi).*r;
z=sin(psi).*r;
surf(x,y,z)
shading interp
By the way, to draw sphere you could use sphere function:
sphere
axis equal

Ben
Ben 2011 年 11 月 16 日
It's not that simple, r is not constant. So I am not plotting a sphere. I'll post the full code, so maybe you can help me...
St11=100;
Sc11=St11*2/3;
St22=80;
Sc22=St22*2/3;
S=60;
for phi=0:pi/50:2*pi
phi*360/(2*pi);
if cos(phi)>=0
X=St11;
else
X=Sc11;
end
if sin(phi)>=0
Y=St22;
else
Y=Sc22;
end
for psi=-pi/2:pi/50:pi/2
psi*360/(2*pi);
F=@(r0)(((cos(phi)*cos(psi)*r0)/X)^2-(cos(phi)*cos(psi)*r0*sin(phi)*cos(psi)*r0)/(X^2)+((sin(phi)*cos(psi)*r0)/Y)^2+(r0*sin(psi)/S)^2-1)^2;
r=abs(fminsearch(F,0));
i=i+1;
x(i)=[cos(psi)*cos(phi)*r];
y(i)=[cos(psi)*sin(phi)*r];
z(i)=[sin(psi)*r];
end
end
plot3(x,y,z)
The performance of the plot is very bad and not nice to look at. Calculationtime approx. 30 seconds...
  2 件のコメント
Ben
Ben 2011 年 11 月 16 日
AWESOME! ;) thank you for you time!
Ben
Ben 2011 年 11 月 16 日
*your time!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeComputational Geometry についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by