How to plot a matrix with reoccurring values?

How would I be able to plot matrix with a reoccuring value such as:
[x y]
[x1 y]
[x1 y1]
[x y1]
[x y2]
[x1 y2]
[x1 y3]
[x y3]
where x=x, x1=x-some number, y=y, y1=y-some number, y2=y1-some number, y3=y-some number. I am trying to create a zig zag pattern onto a map using long and lat but do now really know how I would be able to plot it. I was thinking that it would be the same as plotting a regular matrix but am not sure if it the same values would affect the plot in a way that the points would not show up.

 채택된 답변

ME
ME 2019년 12월 6일

1 개 추천

Take for example a matrix:
vals = [1 1;2 1;2 2; 1 2; 1 3; 2 3; 2 4; 1 4];
which is of the form you describe above. Then do:
plot(vals(:,1),vals(:,2))
This gives the following output - is that about what you wanted?
output.png

댓글 수: 4

Erick Magana
Erick Magana 2019년 12월 6일
편집: Erick Magana 2019년 12월 6일
Thank you, one more question what does the ,1 in the vals(:,1) mean? Also the ,2?
Does that have anything to do with the values that were put into the matrix?
ME
ME 2019년 12월 6일
편집: ME 2019년 12월 6일
The 1 and 2 just indicate the column of the matrix. It is just a way of getting the first column (vals(:,1)) to plot against the second column (vals(:,2)).
For example if you had
A = [1 2 3
4 5 6
7 8 9];
Then
A(:,1) = [1; 4; 7];
Thank you so much it worked!!
ME
ME 2019년 12월 6일
Not a problem. If you found this answer helpful, could you possibly accept it?

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Spline Postprocessing에 대해 자세히 알아보기

질문:

2019년 12월 6일

댓글:

ME
2019년 12월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by