Contour Plot to Image.jpg

조회 수: 9 (최근 30일)
Peter
Peter 2014년 12월 30일
편집: Peter 2014년 12월 30일
Hello!
I need to know how to save or export a 2D Contour plot into an Image file (preferible with .jpeg extension).
I would like also to be able to specify the output location (the folder where the image will be saved), I have tried with this:
contourf(xx,yy,turbul_interp);
xlabel('AXIS X')
ylabel('AXIS Y')
hgsave('name_of_my_image');
But then it appears the following error message:
??? Error using ==> save
Unable to write file name_of_my_image.fig: permission denied.
Any idea about how to do it?. Thanks!
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2014년 12월 30일
Peter - do you have write permissions in the folder where you are trying to create the file? Try specifying the folder name as well...
Peter
Peter 2014년 12월 30일
Thank you Geoff,
In fact i am not specifying any folder, so i do not understand why some permission is denied. I have permission to save everywhere in my PC.
I think that what i want to do is simple, i just want to plot a contour and save it automatically in a folder.
It should be quite easy, just adding some lines to the script to save the contour plot generated as an image.jpg somewhare in my PC . But i am trying and i do not get it...

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2014년 12월 30일
I would not use jpg format. I never create JPEG images. JPEG can/will degrade your image. Use PNG instead.
What does this report in the command window if you call it just before hgsave:
pwd
You probably can't save to that folder.
  댓글 수: 7
Sean de Wolski
Sean de Wolski 2014년 12월 30일
To be fair, in R2014b and newer, I'm not all that convinced that it's necessary. Print has gotten a lot better.
Peter
Peter 2014년 12월 30일
편집: Peter 2014년 12월 30일
Okey, thank you very much to you all.
I finally made it this way:
name = '0050';
fpath = 'C:\Path1\Path2...';
saveas(gca, fullfile(fpath, name), 'png');
And it Worked!!
Anyway i will download export_fig and play with it for a while.
Thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sean de Wolski
Sean de Wolski 2014년 12월 30일
You need to save it somewhere else or have write-permissions for that directory. You could change the directory settings, or run MATLAB as an admin (on Windows right-click the icon, run as admin).

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by