How do I extract subscript numbers from a matrix element?

조회 수: 8 (최근 30일)
Victor Noronha
Victor Noronha 2014년 6월 10일
댓글: Victor Noronha 2014년 6월 10일
Hi, I have a sparse matrix V as you can see.
What I want to do is to extract the rows' subscript numbers and put into a vector matrix X. Example: X = (108, 120, 127, n, ...).
And do the same to col's subscript numbers, putting it into Y = (1, 1, 1, 2, 2, n, ...)
Than, simply plot it using plot(X, Y);
Thank you in advance!

채택된 답변

José-Luis
José-Luis 2014년 6월 10일
편집: José-Luis 2014년 6월 10일
[row,col] = find(V);
plot(row,col,'r+');
  댓글 수: 1
Victor Noronha
Victor Noronha 2014년 6월 10일
Thank you, worked great, but it seems to be rotated 90 degrees counterclockwise.

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

추가 답변 (1개)

Jos (10584)
Jos (10584) 2014년 6월 10일
help find
V = sparse(rand(5)>.5)
[x,y] = find(V)
plot(x,y,'b.')
and take a look at
help spy
spy

Community Treasure Hunt

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

Start Hunting!

Translated by