save a plot

Hi Hi,
i have a problem with saving a plot in a directory as a figure(.tif). I have a main function. Each time i run my code, the code reaches a directory, takes image sequence and make some outputs. What i need to do, is to save some output plots in a directory. I know how to save a figure, but it does not work for plots! (specially i have a figure with hold on and i make plot inside the figure and want to save it!)
Thanks,
Azi

2 个评论

It isn't clear to me what you are asking. Can you include code for a very simple example?
azarm
azarm 2011-8-17
i meant : print('-dtiff','plot.tif')

请先登录,再进行评论。

 采纳的回答

the cyclist
the cyclist 2011-8-17
Does this work for you?
plot(1:10)
print('-dtiff','plot.tif')

7 个评论

azarm
azarm 2011-8-17
tnx, it works :)
azarm
azarm 2011-8-17
I used:
print('-dtiff','example.tif')
now, i need to save the image (example.tif) in a specified directory.
My code is:
baseFileName = sprintf('TEST%d.tif', j);
fullFileName = fullfile(pathName, baseFileName);
imwrite(example, fullFileName);
but this error occurs: ??? Undefined function or variable 'example'
any idea?
tnx, Azi
Two points:
(1) The most basic error you are making is that with your syntax, MATLAB is looking for a variable named "example", which does not exist. I guess you meant to use 'example.tif' (enclosed in single quotes so it interprets that as a string, not a variable).
(2) I am now not 100% sure what you are trying to do, but if you are just trying to save a MATLAB plot, you do not need to use imwrite. You just need to use print(), but with the full file name specified. Will this do what you want?:
print("-dtiff",fullFileName)
azarm
azarm 2011-8-17
(1) well. i tried 'example.tif' as input to imwrite but the
first argument should not be a string!
(2) I want to do exactly this job. But there are some points. I take some images from a folder, run the code, take some figures and plots. So i want to save them in a new folder with proper name.
example1.tif
example2.tif
.
.
.
the index should be created outomatically. that's the reason i used : sprintf('TEST%d.tif', j); (j would be incremented in the code)
any idea how can i do it?
tnx
Azi
If you can create a variable with the full path to the directory, which you seem to be able to do, then you should be able to use
print('-dtiff',fullFileName)
as I said before. (I accidentally used double quotes instead of single quotes before.)
azarm
azarm 2011-8-17
you're right! It works.
Tnx for your help
your answer works, thanks

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Graphics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by