2011-04-12 95 views
8

可变我想做MATLAB - 在情节标题

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

但设置标题不起作用。为什么?

回答

10

因为你忘了添加sprintf

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

num2str应该也适用。

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