Error using subplot using for loops: subplot index too large
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
The following command opens a blank (grey) figure window. It also opens subplot.m directly at the line:
error(message('MATLAB:subplot:SubplotIndexTooLarge'));
I followed advice related to this question and added the loopVar, but something is still incorrect.
How could I plot 16 subplots? (yA, yB and yC are 1x5 double variables)
Thanks!
loopVar=0;nVals1=4;rvals=5;
for val1idx=1:nVals1
for ivalue=1:4:12
figure(14)
indexplot=loopVar+ceil(ivalue/3);
subplot(nVals1,4,indexplot)
ystarIMr=mean(yA(val1idx,1:nVals2,:,ivalue),3);
plot(rvals,ystarIMr,'LineWidth',3,'LineStyle','-')
hold on
plot(rvals,mean(yB(val1idx,1:nVals2,:),3),'LineWidth',3,'LineStyle','--')
plot(rvals,mean(yC(val1idx,1:nVals2,:),3),'LineWidth',3,'LineStyle','-.')
end
loopVar = loopVar + val1idx;
end
0 Commenti
Risposte (1)
Steven Lord
il 18 Set 2020
Set a conditional breakpoint on the line where you call subplot. The condition is nVals1*4 < indexplot. Run your code. When MATLAB stops at that breakpoint, what are the values of nVals1 and indexplot? Do those values make sense in the context of the underlying problem you're trying to solve with your MATLAB code?
If you have a 3-by-4 grid of subplots, where should subplot 13 be created?
Vedere anche
Categorie
Scopri di più su Subplots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!