How to save a graph using print and rational numbers within image name without changing the file format?

조회 수: 1 (최근 30일)
MOTIVATION: The lines below display one example of how I'm trying to name a graph and save the image to the hard disk:
i=10.5;
f=figure;
x = 0:pi/100:2*pi;
y = sin(x-i);
h=plot(x,y);
title(sprintf('ATITLE%g',i));
print(f,'-dtiff', sprintf('ATITLE%g',i));
PROBLEM: When you run these lines, you will see that the file saved is not ATITLE10.5.tif but only ATITLE10.5 anything that I can't use.
QUESTION: I wonder if someone knows how to correct these lines so that the file saved is ATITLE10.5.tif?
I already tried the following approach suggested by Walter:
print(f,'-dtiff', genvarname(sprintf('ATITLE%g',i)));
But the result is ATITLE100x2E5.tif and does not help either.
I thank you in advance for your help Emerson

채택된 답변

Image Analyst
Image Analyst 2012년 2월 4일
Our daily "how do I save a figure?" question. See the FAQ:
If you insist on "rolling your own" then try this:
baseFileName = sprintf('ATITLE%g',i)
folder = pwd;
fullFileName = fullfile(folder, [baseFileName, '.tif'])
title(baseFileName);
print(f,'-dtiff', fullFileName);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by