how to use num2str on print?

4 ビュー (過去 30 日間)
Beatriz Sanchez
Beatriz Sanchez 2018 年 10 月 28 日
コメント済み: Beatriz Sanchez 2018 年 11 月 8 日
hello, so I'm trying to print an image, but this image run several times with different values of two parameters (alpha and p). What I want is that matlab print all of this images with their parameters values with different names. I tried to do this:
print (strcat('Densidades Promedio.', 'alpha='num2str (alpha),'. p='num2str(p)), '-dpng')
but then it gave me an error: "Unexpected MATLAB expression". Any idea about how to do it? thank you

採用された回答

Image Analyst
Image Analyst 2018 年 10 月 28 日
You don't have a comma before the num2str(). Anyway, try it like this (it's more robust):
baseFileName = sprintf('Densidades Promedio.alpha=%f. p=%f', alpha, p)
% What - no extension???
fullFileName = fullfile(pwd, baseFileName);
if exist(fullFileName, 'file')
print(fullFileName);
else
message = sprintf('File not found:\n%s', fullFileName);
uiwait(warndlg(message));
end
  6 件のコメント
Image Analyst
Image Analyst 2018 年 10 月 30 日
I didn't really look into the print part before, but what exactly are you trying to print()? I don't see a use case for print() in the help where it takes only a filename. Do you want to print the current figure? Try passing in a figure handle. Or you want to print something else?
Beatriz Sanchez
Beatriz Sanchez 2018 年 11 月 8 日
thank you very much for your answer, it turns out that the file where I was trying to save the image was damage and for that reason it didn't worked.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by