How to implement a for loop on figure plotting?

조회 수: 1 (최근 30일)
Nisar Ahmed
Nisar Ahmed 2022년 5월 19일
댓글: Image Analyst 2022년 5월 19일
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?

답변 (1개)

Star Strider
Star Strider 2022년 5월 19일
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
Star Strider
Star Strider 2022년 5월 19일
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 2022년 5월 19일
@Nisar Ahmed you keep forgetting to attach your data in a .mat file with the paperclip icon. That would help.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by