How to call multiple subplots in one code?
Mostra commenti meno recenti
I am trying to plot 2-subplots for two scenarios - scenarios 1 and 2, and for two variables - 'temp' and 'weat'. I want results for the 'temp' variable for Scenario 1 and Scenario 2 to appear in one graph. Similarly, I want results of the 'weat' variable to appear in a different sub-plot. Here is my code:
<code lines>
for scenario = 1:2
<code lines that calculate 'temp' and 'weat' variables for both scenarios 1 and 2. In other words, here I've included lines that calculate distinct values for 'temp' and 'weat' for both scenarios>
% Make Figure 1
if scenario == 1
fig1 = subplot(1,2,1);
plot(temp, 'k:');
hold on
elseif scenario == 2
fig1 = subplot(1,2,2);
plot(temp, 'k:');
<save commands for saving Figure 1>
end
% Make Figure 2
if scenario == 1
fig2 = subplot(1,2,1);
plot(weat, 'k:');
hold on
elseif scenario == 2
fig2 = subplot(1,2,2);
plot(weat, 'k:');
<save commands for saving Figure 2>
end
end
The issue is that when Figure 1 is made, the 'temp' and 'weat' variables for scenario 1 appear in Figure 1, and the 'temp' and 'weat variables for scenario 2 appear in Figure 2. What I would want to do is to have Figure 1 with 'temp' results for scenarios 1 and 2; and Figure 2 with 'weat' results for scenarios 1 and 2. I've tried to label the figures as fig1 and fig2, but the issue still persists. I wonder if there is a solution to this issue? I would like to try a solution where I can label the figures distinctly so that the results only appear in the desired figure. Thank you for your help.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Subplots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!