Hi guys,
I tried to transform a profil of a mountain made by hand into a matrix (distance, height).
%profil by hand
height = [1450:50:2000]; %unit m
height = fliplr(height); %flip the vector
x = [0 60 240 840 1110 1290 1620 1890 2010 2040 2160 3000]; %unit m
h = plot(x,height);
But I don't know how to transform my 2 vectors of 12 elements (because I only took 12 points by hand) into a matrix of dimensions [3000, 2]. The aim is to have one value of the height each meter (as we can see on the graph because the points are link up).
Can you help me?
Thanks in advance, Adrien.

댓글 수: 2

Jan
Jan 2016년 12월 28일
The question is not clear. What exactly is "matrix [x,2]"? There is no "[12,2] matrix" in your code. Therefore it is impossible to guess, whow you would like to "transform" it.
Adrien
Adrien 2016년 12월 28일
Yes, sorry my question wasn't clear. Check my correction.
Thanks.

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

 채택된 답변

John D'Errico
John D'Errico 2016년 12월 28일
편집: John D'Errico 2016년 12월 28일

1 개 추천

You don't have a "graph". Merely a sparsely sampled list of points, that you now want to sample more finely. That problem is called interpolation.
help interp1
At least, that is what I presume you are looking for, i.e., how to interpolate.
You won't have 3000 points, but 3001, again assuming that you want what you said if you want a point every meter, 0:3000.

추가 답변 (1개)

Adrien
Adrien 2016년 12월 28일

0 개 추천

Thanks John, it's was exactly this! Sorry again for my lack of clarity.
Best, Adrien.

카테고리

질문:

2016년 12월 28일

답변:

2016년 12월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by