Matlab - variable in the plot title

I want to make

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

but the header setting does not work. Why?

+8
matlab plot
source share
2 answers

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 
+10
source share

num2str should also work.

 title(['N = ',num2str(i)]); 
+7
source share

All Articles