Reputation: 21865
I have 3 vectors , one for angles of Phi
, another for angles of Teta
, and the last one a vector of points in the Y axe
,after computing the points of Teta
& Phi
with a function :
for teta = 0 : 10^-2 : pi/2
for phi = 0 : 10^-2 : pi/2
Y(current) = v*sin(phi)*sin(teta);
Teta(current) = teta;
Phi(current) = phi;
current = current + 1;
end
end
How can I plot the three of them together ?
I want to plot a 3d
graph with Teta
& Phi
as a function of Y
.
I've tried with plot3
but the result wasn't so satisfactory .
Thanks
Upvotes: 2
Views: 1667
Reputation: 12693
I'm unclear about the exact goals, but here's my interpretation:
teta = 0:.01:pi/2;
phi =0:.01:pi/2;
[t p]=meshgrid(teta,phi);
Y = v*sin(p)*sin(t);
surf(t,p,Y)
xlabel('teta')
ylabel('phi')
zlabel('1*sin(teta)*sin(phi)')
Create vectors of teta
and phi
values, use meshgrid
to produce a matrix of t and p values, and use the vectorized form of sin
(rather than a for
loop). Then use surf
to plot the results as a surface in 3D.
Upvotes: 2
Reputation: 6924
This one is ok? I've made step larger and set v as 1.
current = 1;
for teta = 0 : 10^-1 : pi/2
for phi = 0 : 10^-1 : pi/2
Y(current) = 1*sin(phi)*sin(teta);
Teta(current) = teta;
Phi(current) = phi;
current = current + 1;
end
end
plot3(Teta,Phi,Y);
xlabel('Teta')
ylabel('Phi')
zlabel('Y')
grid on
Upvotes: 1