필터 지우기
필터 지우기

Plotting Matrix points

조회 수: 6 (최근 30일)
B_Richardson
B_Richardson 2011년 7월 19일
Hello everyone!
I have a 2 by 10 matrix:
B =
28.7636 27.7497
26.7351 25.7208
23.6934 22.6793
20.6512 19.6371
18.6241 17.6092
15.5820 14.5679
13.5537 11.5246
10.5116 9.4974
8.4835 6.4551
5.4414 4.4273
I am trying to figure out how to plot these matrix points in pairs:
28.7636 27.7497 % start of first point and end of first point
26.7351 25.7208 % start of 2nd point and end of 2nd point
And so on...
I haven't been able to determine the correct plot syntax to accomplish this. Matlab has so many commands when it comes to plotting I dont even know where to start!
Thank in advance!
  댓글 수: 5
B_Richardson
B_Richardson 2011년 7월 20일
Guys, I'm going to post this in a new question because this one has become too confusing! I;m going to name it Plotting Matrix points: 2
Fangjun Jiang
Fangjun Jiang 2011년 7월 20일
Your figure is almost done with the Horizontal lines solution I provided.

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

채택된 답변

Walter Roberson
Walter Roberson 2011년 7월 19일
If you do not want to loop over line(B(K,1),B(K,2)) then you can use this trick:
X = reshape(B(:,1),2,[]);
X(3,:) = nan;
X = X(:);
Y = reshape(B(:,2),2,[]);
Y(3,:) = nan;
Y = Y(:);
plot(X,Y)
This introduces a nan after every second point, and then zips everything back together. nan are treated as indicating a break in plotting.
Jan, I think it was, pointed out to me that inf could be used in place of nan for this purpose, and that most modern cpus handle inf more quickly than they handle nan.
  댓글 수: 5
B_Richardson
B_Richardson 2011년 7월 19일
I think this might work. Let me translate in into GUIDE and see how it looks with the correct data. Its very similar to the effect of stem.
Walter Roberson
Walter Roberson 2011년 7월 20일
plot(repmat(ConstantX, 1, size(B,1)), B.', 'b-o')

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

추가 답변 (4개)

Sean de Wolski
Sean de Wolski 2011년 7월 19일
line(B(:,1),B(:,2))
maybe?
What do you mean by start of first and end?
  댓글 수: 1
B_Richardson
B_Richardson 2011년 7월 19일
I will try to illustrate:
_____--___--____--____
each dash represents a matrix element the solid line is the overall length of a video:
dash 1,2 = 28.7636 27.7497
dash 3,4 = 26.7351 25.7208
dash 5,6 = 23.6934 22.6793
It doesnt have to appear exactly like that but the idea is to display them in order of pairs from start to finish. This is for segmentation of a video. I'm going to plot them over the over length of the video in an GUIDE axis.

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


Fangjun Jiang
Fangjun Jiang 2011년 7월 19일
Not enough information. Your B is 10x2 matrix, not 2x10. Maybe:
a=[1:10;1:10];
line(a,B');
Horizontal lines:
line(B',zeros(2,10));
hold on;
plot(B,zeros(10,2),'o');
Vertical lines:
line(zeros(2,10),B');
hold on;
plot(zeros(10,2),B,'o');
  댓글 수: 7
Fangjun Jiang
Fangjun Jiang 2011년 7월 20일
Should the start time be less than the stop time? Maybe it doesn't matter. Should horizontal lines be more suitable than vertical lines since they indicate time lapse? Anyway, see edit in my answer for both options.
B_Richardson
B_Richardson 2011년 7월 20일
I'm going to try both and see which one is closer to what I'm trying to accomplish

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


Paulo Silva
Paulo Silva 2011년 7월 19일
stairs(B) %just one wild guess
  댓글 수: 1
B_Richardson
B_Richardson 2011년 7월 19일
I tried it but the plot it produces is not easy to distinguish the lines

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


B_Richardson
B_Richardson 2011년 7월 19일
Hey everybody, look try
B =rand(10,2)
stem(B)
this is kinda what I'm trying to do. Notice how it produces 10 lines. On each of those lines there are 2 points for a total of 20 points.
  댓글 수: 3
B_Richardson
B_Richardson 2011년 7월 19일
oh, my apologies. It really doesnt matter what form its in (points, lines, dots, lol, etc)
And I prefer them spread across the same x value. But I'm just trying to visually display the 20 points with the connections 1,2 3,4 5,6 and so on to produce 10 distinct marks/lines/points.
B_Richardson
B_Richardson 2011년 7월 19일
I think i may be confusing myself here (and everybody else), wouldnt I need to include a varilbe that contains the overall length of the video in the plot command somewhere? Or would that just be in the axis?

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

카테고리

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