开发者

matlab - variable in plot title

开发者 https://www.devze.com 2023-02-24 03:34 出处:网络
I want to do for i = 1 : size(N, 2) figure(i); title(\'N = %d\', i); %other stuff but setting the title doesn\'t work.开发者_Python百科 Why?Because you forgot to add sprintf

I want to do

for i = 1 : size(N, 2)
    figure(i);
    title('N = %d', i);
%other stuff

but setting the title doesn't work.开发者_Python百科 Why?


Because you forgot to add sprintf

for i = 1 : size(N, 2) 
figure(i); 
title(sprintf('N = %i', i)); %# %i for integer
%other stuff
end


num2str should also works.

title(['N = ',num2str(i)]);
0

精彩评论

暂无评论...
验证码 换一张
取 消