Create a loop to read a matrix

조회 수: 9 (최근 30일)
Miguel Albuquerque
Miguel Albuquerque 2022년 5월 24일
댓글: dpb 2022년 5월 25일
Hey guys, this is probably very easy, but im finding it difficult to do
I have a matrix surv_matrix, that assumes values of 0 and of a signal in frequency. this matrix only has values of a signal in frequency, along the column in specific columns. So imagine this matrix is 23979 by 400, and has values different from zero in column 200, 201 and 202. Along that 3 columns, this matrix assumes values to all the 23979 rows.
I want to identifie the columns that have values diferent from zero, and when it finds all the 3 columns do this code, for each column
plot(abs(freq_XQPSK),20*log10(abs(X_QPSK)),'b','linewidth',2);
xlim ([20e6 60e6]);
thanks a lot

채택된 답변

dpb
dpb 2022년 5월 24일
ic=find(~all(surv_matrix==0));
will return your three column indices to use to index into the array.
You haven't defined where the variables referred to in the plot command come frome...some operation over those three columns of the array, one presumes.
  댓글 수: 10
Miguel Albuquerque
Miguel Albuquerque 2022년 5월 25일
Thanks a lot man, your code was exactly what I wanted, I can see the separate lines in one plot.
But is there any way I can change the color of the lines and put a legend on it?
dpb
dpb 2022년 5월 25일
That's why saved the line handles -- see <plot>, it gives example of changing after the line creation.
hL is an array of l ine handles; one for each line, use either one of the named basic eight colors or any RGB triplet for color.
<legend> is how legends are added -- simply write the text you want for each in sequence as they're drawn and it's done for the simplest case --
hLg=legend('Line A','Line B','Line C');
You can get as creative as you care to...use the doc to learn about all the properties -- there are many examples to guide the beginner...

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by