How to visualize a matrix?

조회 수: 4 (최근 30일)
Timur
Timur 2013년 3월 7일
Hi,
I have matrix
00001
00000
00000
01000
How I can visualize this, assuming that values "1" are points, that have to be connected by a line? I'd like to end up with such plot:
So coordinates of connected points are positions of elements in matrix that have value=1
Thanks
  댓글 수: 4
Matt J
Matt J 2013년 3월 7일
You don't seem to be using the same coordinate system for each point. you seems to be using 0-based coordinates for the lower-left point, which is why it lies at (0,1). However, the 0-based coordinate of the upper-right point should then be at (4,3) not (5,4).
Timur
Timur 2013년 3월 7일
Matt J, Yes, was just in a hurry while plotting an example. Azzi Abdelmalek, yes

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

채택된 답변

Matt J
Matt J 2013년 3월 7일
편집: Matt J 2013년 3월 7일
[I,J]=find(yourMatrix);
plot(J-1,size(yourMatrix,1)-I) %in 0-based coordinates
  댓글 수: 2
Timur
Timur 2013년 3월 7일
Thanks!
Matt J
Matt J 2013년 3월 7일
It should start at 2, i suppose.
If you're saying you now want 1--based coordinates, just change the above to
plot(J,size(yourMatrix,1)-I+1)

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

추가 답변 (1개)

Youssef  Khmou
Youssef Khmou 2013년 3월 7일
hi,
try simply :
f=[ 00001
00000
00000
01000];
plot(f);
You will get the same plot as your figure, except the slope starts at 3.
But in your question, one can think that you want to visualize MxN array ,
  댓글 수: 1
Timur
Timur 2013년 3월 7일
that doesn't plot what I want to see. It should start at 2, i suppose.

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

카테고리

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