There is nothing wrong with MATLAB. You are getting the same plots because you are plotting same vectors 4 times. Just look at YData of plot() function in your script. You are only changing XData and the x-axis of all 4 subplots are different.
Multiple Subplots from the Same While Function
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm trying to do a parametric study of four different variables within the same plot. The code currently generates the four subplots, but the data points are identical for all four and correspond to whichever subplot i have first in the code.
How can I get it to produce four unique subplots from this one while function?
%Otto Cycle
%TcritOCT = CoolProp.Props1SI ('Octane', 'Tcrit'); %fluid needs to be changed
n=20;
Tmin = 20.85+273.15;
Tmax = 1000;
Pmin = 200;
Rco = 10;
Rcoset = linspace(5,15,n);
Tminset = linspace(200,400,n);
Tmaxset = linspace(600,1000,n);
Pminset = linspace(200,400,n);
R = 0.287;
Cv = 0.717;
Cp = 1.004;
K = 1.4;
nn=0;
while nn<n
nn = nn+1;
%if Tmaxset > TcritOCT
%disp('T max is larger than the critial temperature')
%disp('Program stops')
%return
%end
Rco=Rcoset(nn);
Tmin=Tminset(nn);
Tmax=Tmaxset(nn);
Pmin=Pminset(nn);
t1 = Tmin
v1 = (R*Tmin)/Pmin
v2 = v1/10
t2 = Tmin*Rco^(K-1)
v3 = v2
t3 = Tmax
v4 = v1
t4 = t3*(1/Rco)^(K-1)
wcom = Cv*(t2-t1)
qsup = Cv*(t3-t2)
wout = Cv*(t3-t4)
qwas = Cv*(t4-t1)
eta (nn)= (qsup-qwas)/qsup*100
wnet (nn)= wout-wcom
end
figure('Color',[1 1 1])
subplot(221);
yyaxis left
plot(Rcoset,eta,'*b');
ylabel('Cycle Efficiency (%)');
yyaxis right
plot(Rcoset,wnet,'*g');
xlabel('Compression Ratio');
ylabel('Net Work (kJ/kg)');
grid on;
title('Compression Ratio Study');
subplot(222);
yyaxis left
plot(Tminset,eta,'*b');
ylabel('Cycle Efficiency (%)');
yyaxis right
plot(Tminset,wnet,'*g');
xlabel('Minimum Temperature oC');
ylabel('Net Work (kJ/kg)');
grid on;
title('Minimum Temperature Study');
subplot(223);
yyaxis left
plot(Tmaxset,eta,'*b');
ylabel('Cycle Efficiency (%)');
yyaxis right
plot(Tmaxset,wnet,'*g');
xlabel('Maximum Temperature oC');
ylabel('Net Work (kJ/kg)');
grid on;
title('Max Temparature Study');
subplot(224);
yyaxis left
plot(Pminset,eta,'*b');
ylabel('Cycle Efficiency (%)');
yyaxis right
plot(Pminset,wnet,'*g');
xlabel('Minimum Pressure oC');
ylabel('Net Work (kJ/kg)');
grid on;
title('Minimum Temperature Study');
clear
0 commentaires
Réponses (1)
Voir également
Catégories
En savoir plus sur Subplots 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!