Plots in a loop

Assume I had a matrix of dimension nX20. I want to plot each column using a loop, but there is some problem in giving a title for each plot in a loop. I want to give the titles data1, data2 and so on for each plot. My loop looks like this:
figure(k)
surf(squeeze(X),squeeze(Y),reshape(data(:,k),size(squeeze(X))),'edgecolor','none')
view(2)
axis equal
axis tight
set(gcf,'renderer','painters')
title('data')
colorbar
end

Answers (1)

Star Strider
Star Strider on 13 Jul 2022

0 votes

Perhaps:
title(sprintf('data %3d',k))
.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Release

R2022a

Asked:

on 13 Jul 2022

Answered:

on 13 Jul 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!