Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
matlab-绘图标题中的变量_Matlab_Plot - Fatal编程技术网

matlab-绘图标题中的变量

matlab-绘图标题中的变量,matlab,plot,Matlab,Plot,我想做什么 for i = 1 : size(N, 2) figure(i); title('N = %d', i); %other stuff 但是设置标题是行不通的。为什么?因为你忘了添加sprintf for i = 1 : size(N, 2) figure(i); title(sprintf('N = %i', i)); %# %i for integer %other stuff end num2str也应该起作用 title(['N = ',num2str(

我想做什么

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

但是设置标题是行不通的。为什么?

因为你忘了添加
sprintf

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

num2str也应该起作用

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