How to implement a for loop on figure plotting?

Hi,
The size of f is 1*500, while the size of Q is 115 * 500. I want to plot Q at few selected f values say with the iinterval of 100 etc. How I can code for a for loop?

Respuestas (1)

Try something like this
f = 1:500;
Q = randn(115,500);
idx = 1:100; % Choose Specific Columns
figure
plot(f(idx), Q(:,idx))
grid
.

5 comentarios

Nisar Ahmed
Nisar Ahmed el 19 de Mayo de 2022
@Star Strider the actual plot is given below:
Q is plotted along the depth D and Q is computed at various f (500 Q curves) How can I put a loop to plot few Q (at fixed f intervalm say at 1, 101, 201, 301, and so non)?
I thought the intent was to plot selected rows of ‘Q’ as a function of ‘f’. However now I’m completely confused. I have no idea how ‘f’ and ‘Q’ relate with respect to the plots.
Perhaps something like this —
f = 1:500;
Q = randn(115,500);
% idx = 1:100; % Choose Specific Columns
for k = 1:100:500
figure
plot(Q(:,k))
grid
title(sprintf('f = %d',f(k)))
end
.
Nisar Ahmed
Nisar Ahmed el 19 de Mayo de 2022
@Star Strider thank you but I want to plot on a single plot (all curves on signle plot). How to put here hold on
Try this —
f = 1:500;
Q = randn(115,500);
figure
hold on
for k = 1:100:500
plot(Q(:,k), 'DisplayName',sprintf('f = %d',f(k)))
end
hold off
grid
legend('Location','best')
.
Image Analyst
Image Analyst el 19 de Mayo de 2022
@Nisar Ahmed you keep forgetting to attach your data in a .mat file with the paperclip icon. That would help.

Iniciar sesión para comentar.

Categorías

Más información sobre Graphics Performance en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 19 de Mayo de 2022

Comentada:

el 19 de Mayo de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by