Matlab Plotting Question: No graphs
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Meowooo
le 8 Nov 2019
Réponse apportée : Artemio Soto Breceda
le 8 Nov 2019
![1573185837(1).jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/247337/1573185837(1).jpeg)
![1573185869(1).png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/247338/1573185869(1).png)
Hello Everyone, I am trying to plot the below equilibrium curve by using the plot shown. However, my code does not work.
Is there anything that I missed? Thank you for your help! :)
1 commentaire
Shubham Gupta
le 8 Nov 2019
your x1 & y1 are scalars. which is being plotted as a point on the graph.
plot(x1,y1,'r*')
Above code will show "red asterisk" at that point. But I sure you want x1 & y1 to be vectors, which you won't get unless you use vectors to calculate x1 & y1.
Réponse acceptée
Hiroki Okawa
le 8 Nov 2019
Modifié(e) : Hiroki Okawa
le 8 Nov 2019
Hi, Meowooo
Please try below code.
T1 = 70:90; A1 = 13.8858; B1 = 2788.51; C1 = 220.79;
T2 = 120:140; A2 = 14.0045; B2 = 3279.47; C2 = 213.20;
P = 101.33;
P1sat = exp(A1 - B1 ./ (T1 + C1));
P2sat = exp(A2 - B2 ./ (T2 + C2));
x1 = ((P - P2sat)./(P1sat-P2sat)); % / => ./
y1 = (P1sat/P).*x1; % * => .*
plot(x1, y1);
grid on
0 commentaires
Plus de réponses (1)
Artemio Soto Breceda
le 8 Nov 2019
Your problem is that x1 is a single value, rather than an array. It is actually plotting something, but it is just 1 single dot per element of y1. Try this and you will see what I mean:
plot(x1,y1,'o');
I believe that your problem would be fixed if you use the dot (.) operator to define x1:
x1 = ((P-P2sat)./(P1sat-P2sat)); % This makes x1 an array, instead of a single value
y1 = (P1sat/P).*x1; % Then you need to use the dot (.) operator on this line as well
0 commentaires
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!