Save Histogram data without figure

Hi, I want to save a histogram figure in a folder out of matlab but i do not want that the figure appears on matlab. How can i do this?

 采纳的回答

You can create a figure with the Visible property set to 'off'.
f=figure('Visible','off');
X=randi(15,1,100);
histogram(X,'Parent',f);
saveas(f,'test.png')
close(f)

4 个评论

Thanks!! it's right :) Now I have this problem: i want to save the histogram in a certain folder,but saveas() returns error. The code is: saveas(f,filename); where, f is the histogram while filename is a character vector (''C:\Users\Annagrazia\Desktop\Progetto\Istogrammi\Istogramma_Immagine_01.tif'). The error is: 'Invalid Handle'. How can i solve this?
f is not the histogram, f is the handle to the figure (which in this case contains a histogram). That might seem like a nitpicky point, but it probably points to where your bug is.
I tried to use print instead of saveas, and I use this command: print(percorso,'-dtiff'); where "percorso" is the path of the folder where the image has to be saved. But it returns this error:
Cannot create output file 'C:\Users\Annagrazia\Desktop\Progetto\Cartella\Istogramma_Immagine_01.tif'. Error in print (line 71) pj = name( pj );
How can I change the path where print save the figure? Thanks for helping!!
I don't see any reason why that would fail. What is the complete code you're using? (please use the {}Code button to format your code)

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by