Plot multiple subplot in iteration for each data set.

3 ビュー (過去 30 日間)
Abhi Ove
Abhi Ove 2017 年 2 月 16 日
回答済み: Geoff Hayes 2017 年 2 月 17 日
Dear All,
I have a structure containing 'n' number of fit results (contained in variable fitResults with 1xn struct array). I would like to plot n = 1:5 in subplot(2,5,1). Then plot 6:10 in subplot(2,5,2) and so on until all n number of fitshave been plotted. I can plot all of them in sequence by using,
figure; hold on;
for i = 1: size(fitResults,2)
plot(fitResults(i).fits,x,y)
hline(0,'-r')
pause(5)
end
However I am having trouble separating them in various subplots in batches of 5. I was wondering if you can provide me some advice.
Many thanks in advance.

採用された回答

Geoff Hayes
Geoff Hayes 2017 年 2 月 17 日
Abhi - since you are grouping the results in batches of five, then you could determine the batch "id" as
for k=1:size(fitResults,2)
batchId = ceil(k/5);
hAxes = subplot(2,5,k);
plot(hAxes, ...);
% etc.
end
So on each iteration of the loop, we determine the batch id given the result. With that, we can get the handle to the subplot axes that we wish to plot the data to.
Try the above and see what happens!

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSubplots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by