Symbols work in plot but line doesn't
1 view (last 30 days)
Show older comments
When I choose to display the data in the graph as a symbol (e.g. "*" or "x" or "o") it comes out fine, but when I try to get it to display as a line my graph is blank. My Redlich_Kwong function is working and returning v successfully. Any help as to how to connect up my data points to get a line?
Pressure_vector = [1 1.5 2 2.5 3 5 10 15 25 50 100];
%%%%DATA IS PLOTTED%%%%
for i = 1:11
P = Pressure_vector(1,i);
[v,err,counter] = Redlich_Kwong(R,T,Tc,P,Pc);
plot(P,v,'b*');
hold on;
end
%%%%NO DATA IS PLOTTED%%%%
for i = 1:11
P = Pressure_vector(1,i);
[v,err,counter] = Redlich_Kwong(R,T,Tc,P,Pc);
plot(P,v,'b-');
hold on;
end
0 Comments
Answers (1)
Adam Danz
on 27 Feb 2020
Edited: Adam Danz
on 28 Feb 2020
I assume P and v are both scalar values. If that's the case, the definition of a line requires at least two value. For example, you can draw the point (3,1) but it doesn't make sense to draw the line at (3,1). It would make sense to draw a line from (3,1) to (4,2).
A better approach would be to store the values in the loop and then plot them later. Then you can plot a line.
P = nan(1,11);
v = nan(1,11);
for i = 1:11
P(i) = Pressure_vector(1,i);
[v(i),err,counter] = Redlich_Kwong(R,T,Tc,P(i),Pc); % assuming output is scalar
end
plot(P,v,'b-');
0 Comments
See Also
Categories
Find more on Directed Graphs 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!