Search code examples
matlabmatlab-figure

How to give a Matlab figure title


I would like to give this figure a title, that will depend on each iteration. Something that would mention the number i of the current iteration:

for i = 0:(N-1)
    figure('Name','i','NumberTitle','on')
    subplot(2,2,1)
    ...      
    title('Subplot 1')
    subplot(2,2,2) 
    ...      
    title('Subplot 2')
    subplot(2,2,3)  
    ...    
    title('Subplot 3')
    subplot(2,2,4) 
    ...      
    title('Subplot 4')
end

Ideally, something like:

figure('Name','for the object',i,'NumberTitle','on')

which does not work. Is there any way to do this?


Solution

  • You need the create the figure name string by concatenation:

    figure('Name',['for the object ‘, num2str(i)], ...