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일

0 개 추천

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

Beatriz Sanchez
Beatriz Sanchez 2018년 10월 29일
thanks, but it does not worked, either my option nor yours. It always gave me the message "file not found" every tim and does not save the image. My way does not save the image either.
Image Analyst
Image Analyst 2018년 10월 29일
Then the file does not exist by that exact filename. Check it character for character, including spaces, dots, etc. and whether or not the filename has an extension.
Beatriz Sanchez
Beatriz Sanchez 2018년 10월 29일
but the file does not exist, because what I'm trying to do with 'print' is to create it, right?
Stephen23
Stephen23 2018년 10월 30일
@Beatriz Sanchez: please show the complete error message. This means all of the red text.
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개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

태그

질문:

2018년 10월 28일

댓글:

2018년 11월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by