# Create a plot for a loop

조회 수: 1 (최근 30일)
Miguel Albuquerque . 2022년 5월 24일
댓글: Miguel Albuquerque . 2022년 5월 24일
I have this code, that finds in surv_matrix the indixes where the matrix is different from zero. but for each one of them indices, I want to create a plot, like that, and see one plot for each indice. Is there anyway of creating a better loop, since this one only gives me the last plot. Imagining that ic=3,4,5. I want to see 3 plots, and with this code I m only seeing 1.
Thank you,
ic=find(~all(surv_matrix==0));
for idx=ic
surveillance_column=surv_matrix(:,idx)
plot(abs(freq_XQPSK),(abs(surveillance_column)),'b','linewidth',2);
continue
end

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

### 답변 (1개)

Mustafa Abu-Mallouh 2022년 5월 24일
편집: Mustafa Abu-Mallouh 님. 2022년 5월 24일
Use the 'hold on' command after your plot command, this will put all of your plots on the same axes
hold on
##### 댓글 수: 3표시 이전 댓글 수: 2숨기기 이전 댓글 수: 2
Miguel Albuquerque 2022년 5월 24일
Alright im doing this:
In the case of my example, ic= 197,198,199,200,201,202,203 . But with this code im only seeing the last plot of ic=203, Is there anyway I could see all the 7 plots, without doing it mannually, which means, replacing ic myself.
ic=find(~all(surv_matrix==0));
for idx=ic
surveillance_column=surv_matrix(:,idx);
figure(1);
plot(abs(freq_XQPSK),(abs(surveillance_column)),'b','linewidth',2); hold on
end

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

### 카테고리

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

R2021b

### Community Treasure Hunt

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

Start Hunting!