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 commentaires

Jan
Jan le 28 Déc 2016
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 le 28 Déc 2016
Yes, sorry my question wasn't clear. Check my correction.
Thanks.

Connectez-vous pour commenter.

 Réponse acceptée

John D'Errico
John D'Errico le 28 Déc 2016
Modifié(e) : John D'Errico le 28 Déc 2016

1 vote

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.

Plus de réponses (1)

Adrien
Adrien le 28 Déc 2016

0 votes

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

Community Treasure Hunt

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

Start Hunting!

Translated by