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 comentarios

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

Iniciar sesión para comentar.

 Respuesta aceptada

the cyclist
the cyclist el 17 de Ag. de 2011

2 votos

Does this work for you?
plot(1:10)
print('-dtiff','plot.tif')

7 comentarios

azarm
azarm el 17 de Ag. de 2011
tnx, it works :)
azarm
azarm el 17 de Ag. de 2011
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
the cyclist
the cyclist el 17 de Ag. de 2011
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 el 17 de Ag. de 2011
(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
the cyclist
the cyclist el 17 de Ag. de 2011
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 el 17 de Ag. de 2011
you're right! It works.
Tnx for your help
pedro rivera
pedro rivera el 1 de Abr. de 2013
your answer works, thanks

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Environment and Settings en Centro de ayuda y File Exchange.

Preguntada:

el 17 de Ag. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by