3plot won't give a three-dimensional plot
3 views (last 30 days)
Show older comments
So I am trying to get a three dimensional plot with pressure (p) on the x-, volume (V) on the y- and temperature (Temp) on the z-axis. My code looks like this:
if true
% code
function pressure=func()
% Constantes
R_g=287
L=36.74e-3 %m
r=8.5e-3 %m
theta=[0:0.1*pi:2*pi] %rad
S=2*r %m
d=30e-3 %m
h=1.9e-3 %m
V_cl=(0.25*pi*d.^2)*h
p_atm=1.013e5 %Pa
p_out=1e6 %Pa
kappa=1.35
mcomp=1.2 %kg
mexp=1 %kg
% Dependent Variables
V1=V_cl+(0.25*pi*(d^2))*S %m^3
V2=V1*(p_atm/p_out).^(1/kappa) %m^3
V3=V_cl %m^3
V4=V3*(p_out/p_atm).^(1/kappa) %m^3
Vcomp=[V2:1e-7:V1] %m^3
Vexp=[V3:1e-7:V4] %m^3
function compression=f(Vcomp)
compression=(p_atm.*(V1).^kappa)./((Vcomp).^kappa) %Pa
end
function expansion=g(Vexp)
expansion=(p_out.*(V3).^kappa)./((Vexp).^kappa) %PA
end
Traject1=@f
pcomp=f(Vcomp)
Traject2=@g
pexp=g(Vexp)
%Temperature
function temperature=temp(p,V,m)
temperature=(p.*V)/(m*R_g)
end
Temp1=@temp
Tcomp=temp(pcomp,Vcomp,mcomp)
Temp2=@temp
Texp=temp(pexp,mexp,mexp)
%Graphics
hold on
plot3(Vcomp,pcomp,Tcomp,'red')
plot3(Vexp,pexp,Texp,'green')
hold off
end
end
When I run this, I get no errors yet it only gives me a 2D plot (a pV-diagram). What is going wrong here?
0 Comments
Answers (2)
KSSV
on 15 May 2017
Your plot is 3D plot only......you need to change the orientation of the plot. Two ways..
1. doc view
2. There would be a rotation icon in the plot, click on it and rotate.
0 Comments
KL
on 15 May 2017
Change your function to have the desired variables as outputs, like this
function [Vcomp,pcomp,Tcomp, Vexp,pexp,Texp]=func() %very first line of your code
then you can call the funtion and plot it like this
>> [a,b,c,a1,b1,c1] = func();
>> plot3(a,b,c)
>> hold on
>> plot3(a1,b1,c1)
0 Comments
See Also
Categories
Find more on Specifying Target for Graphics Output in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!