How to save histogram as a png file with the axis values (as it displays in imhist() function ) inside a loop?
28 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sheikh Faishal Basher
el 31 de Mayo de 2018
Comentada: Sheikh Faishal Basher
el 31 de Mayo de 2018
Hello, I am new to matlab, I want to save the histogram as it shows in the imhist function. but when I save it, it only saves the spikes (bars), but, does not save the entire histogram (x and y axis are not saved with with the spikes). also I want to create a histogram in each irritation of the loop and save them with different name, (as Hist11, Hist12, hist21,hist22.....etc) the name will contain the row number and column number. Here is the code I have tried already. Thank You.
imwrite(imhist(temp),'F:\499\Histogram\h1.png');
saveas(im1,sprintf('HIS%d.png',i));
0 comentarios
Respuesta aceptada
Más respuestas (1)
Aditya Salveru
el 31 de Mayo de 2018
Hi,
You can save the entire histogram using as it shows in the imhist functions using the below code snippet.
saveas(gcf,sprintf('HIS%d.png',i))
Run this snippet in the loop to create multiple histograms and save them.
I am giving an example code with loop to create and save multiple histograms.
x=[1 2 2 4 4 5 5 5];
while(length(x)<15)
imhist(x)
saveas(gcf,sprintf('HIS%d.png',length(x)))
x=[x length(x)];
end
Thank you.
Aditya Salveru.
1 comentario
Sheikh Faishal Basher
el 31 de Mayo de 2018
Editada: Sheikh Faishal Basher
el 31 de Mayo de 2018
Ver también
Categorías
Más información sobre Histograms en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!