Plot multiple subplot in iteration for each data set.
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Abhi Ove
le 16 Fév 2017
Réponse apportée : Geoff Hayes
le 17 Fév 2017
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.
0 commentaires
Réponse acceptée
Geoff Hayes
le 17 Fév 2017
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 commentaires
Plus de réponses (0)
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!