Plot multiple subplot in iteration for each data set.

3 visualizaciones (últimos 30 días)
Abhi Ove
Abhi Ove el 16 de Feb. de 2017
Respondida: Geoff Hayes el 17 de Feb. de 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.

Respuesta aceptada

Geoff Hayes
Geoff Hayes el 17 de Feb. de 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!

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by