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