hgexport file appears to be damaged or corrupted
2 次查看(过去 30 天)
显示 更早的评论
I have a figure that I am formatting in my script which I would like to save as a jpg/bmp/png from the script, but preserve the formatting.
I defined the figure and formatting:
fig1=figure('units','normalized','outerposition',[0 0 1 1]);
then plotted several things, and tried to output:
hgexport(fig1,'Test.bmp','units','normalized','outerposition',[0 0 1 1])
The figure is created as a bmp in the working directory, but when I try to open the image I get the message "Windows Photo Viewer can't open this picture because the file appears to be damaged, corrupted, or is too large". I get the same message if trying to open the image in paint or powerpoint.
Is there some other way to save the figure as an image from the script and preserve the formatting? I have also tried saveas and print, but the formatting/size is wrong. I am on R2015b.
Thanks
0 个评论
回答(1 个)
Walter Roberson
2017-7-6
"hgexport(fig,filename) writes figure fig to the EPS file filename."
You have a EPS file named as a .bmp
2 个评论
Walter Roberson
2017-7-6
No, not unless you count a .fig file as being an "image file". Every other image file type is static and will lose some information compared to what MATLAB knows.
If you were to indicate particular information that needed to be preserved, there is a possibility that someone might have ideas.
Did you try export_fig from the File Exchange ?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Printing and Saving 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!