Save histogram graphs during for loop operation

Hi,
I got my data stored in the form of 100 x 192, I am generating one histrogram plot per 8 columns of data. This means, finally 24 histogram plots. May I know, how to save one histogram plot for every 8 iteration!!!
for i = 1:1:192
BB = Data (:,i);
histogram(BB);
hold on
end

 Risposta accettata

n = 1;
for i = 8:8:192
Data = rand(100,192);
BB = Data (:,n:i); n = i;
f=figure;
histogram(BB);
saveas(f, ['histogram' num2str(i/8) '.png'])
hold on
end
exportgraphics in case you are using above 2020
% Requires R2020a or later
exportgraphics(f,['histogram' num2str(i/8) '.png'],'Resolution',300)

4 Commenti

Thanks a lot.. However, I intend to overlay the data of 8 cloumn on single histogram (similar to the herewith attached figure), save and then continue the loop for next 8 column and so on
Data = rand(100,192);
n = 8;
for x = 1:1:24
f=figure;
j = n*x
for i = j-7:j
BB = Data(:,i);
histogram(BB);
hold on
end
saveas(f, ['histogram' num2str(x) '.png'])
end
Thanks a lot.. This is perfect !!!
Thank you!!!!

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by