Error using subplot using for loops: subplot index too large
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Steven Lord
2020 年 9 月 18 日
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?
参考
カテゴリ
Help Center および File Exchange で Subplots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!