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 commentaires

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

Connectez-vous pour commenter.

 Réponse acceptée

the cyclist
the cyclist le 17 Août 2011

2 votes

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

7 commentaires

azarm
azarm le 17 Août 2011
tnx, it works :)
azarm
azarm le 17 Août 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 le 17 Août 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 le 17 Août 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 le 17 Août 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 le 17 Août 2011
you're right! It works.
Tnx for your help
pedro rivera
pedro rivera le 1 Avr 2013
your answer works, thanks

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Environment and Settings dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by