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 件のコメント

Oliver Woodford
Oliver Woodford 2011 年 8 月 17 日
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 日

2 投票

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
the cyclist
the cyclist 2011 年 8 月 17 日
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
the cyclist
the cyclist 2011 年 8 月 17 日
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
pedro rivera
pedro rivera 2013 年 4 月 1 日
your answer works, thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by