Plotting and adding elements to an array
Show older comments
%Tc = input('PLease enter the critical temperature'); %Critical Temp. in Kelvins
Tc = 154.6;
%Pc = input('Please enter the critical pressure'); %Critical Pressure in MPa
Pc = 50.46;
%omega = input('Please enter the omega value of the Peng_robinson EOS');
omega = 0.021;
k = 0.37464 + (1.54226 - 0.26992*omega)*omega;
R = 0.08314; %gas constant in MPa*m3/mol*K
%v = input('Please enter a vector of pressure');
v = 1:10:100;
%n = input('Please enter a vector of temperature');
n = [173 198 223 248 273 298 323 348 373 398 423];
%n = 173;
b = 0.077796074*R*Tc/Pc;
x=[];
for P = v
for T = n
alpha = (1 + k*(1-sqrt((T/Tc))))^2;
a = 0.457235529*(R*Tc)^2/Pc*alpha;
B = b.*P/(R*T);
A = a.*P/((R*T)^2);
ZZ = ZZroot(A,B);
V = ZZ*R*T./P
end
x(end+1)=V;
end
What I am trying to do is, if possible, is for each element n, I add the values V computed for each corresponding different P(small v) to an array. For example,
[V(1) ; V(2) ; V(3); ...].
| v(1) v(2) v(3) ...| <- pressure small v
n(1)| V(1) V(2) V(3) ...|
n(2)| V(1) V(2) V(3) ...|
n(3)| V(1) V(2) V(3) ...|
.
.
.
Once I do that, I would like to plot each row as its own line in the same graph. x axis would be V and y axis v(small v).
Hope that makes sense. Thanks in advance.
2 Comments
Guillaume
on 24 Aug 2015
Am I understanding correctly that you already know the y-axis values (the small v you start with), and that you are actually calculating the x-axis values (the big V) with your code?
And in the end, there is only one set of y-axis values but several sets of x-axis value (of for each n). Therefore all the curves have the same y-coordinates but for different x coordinates?
Abdullah Al-Alawi
on 25 Aug 2015
Edited: the cyclist
on 25 Aug 2015
Accepted Answer
More Answers (0)
Categories
Find more on Mathematics 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!