Resample a matrix with a defined interval

4 Ansichten (letzte 30 Tage)
Jules Ray
Jules Ray am 5 Nov. 2013
Kommentiert: Jules Ray am 5 Nov. 2013
Hello dear colleagues, i'm working with two different matrix of time v/s height. So, i want to resample the matrix by time but i dont know how.
these two matrix are the examples that i want to resample, each one is a separated example. In matrix A and B the first colum represent the time and the second the elevation. As you see in matrix A the time interval is regular (0.2), but in matrix B is not regular.
A=
-13 -86.7
-13.2 -83
-13.4 -85
-13.6 -89
-13.8 -100.5
-14 -105.1
-14.2 -109.3
-14.4 -121
-14.6 -119.8
-14.8 -107.2
-15 -108.6
-15.2 -109.7
-15.4 -111.3
-15.6 -114.6
B=
8.6001 16.735
8.7 17.215
8.8 17.775
8.8999 18.324
9 18.932
9.1001 19.595
9.2 20.265
9.3 20.982
9.3999 21.745
9.5 22.556
9.6001 23.374
9.7 24.218
9.8 25.063
9.8999 25.918
10 26.764
10.1 27.603
10.2 28.45
10.3 29.267
10.4 30.086
10.5 31.017
10.6 32.051
10.7 33.119
What i need is to resample the matrixes by a defined time interval (instead of number of rows), for instance, for matrix A, i would like to resample the matrix based in a 0.05 time interval. And for Matrix B i would like to resample the matrix based in a 1.0 time interval.
How can i do that in matlab?
thanks in advance

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 5 Nov. 2013
Bearbeitet: Azzi Abdelmalek am 5 Nov. 2013
You can use interp1 function to interpolate
x=A(:,1);
y=A(:,2);
xi=x(1):-0.05:x(end);
yi=interp1(x,y,xi);
new_A=[xi',yi']
  3 Kommentare
Azzi Abdelmalek
Azzi Abdelmalek am 5 Nov. 2013
Bearbeitet: Azzi Abdelmalek am 5 Nov. 2013
Your data in A are sorted in descending order, -13>-13.2
Jules Ray
Jules Ray am 5 Nov. 2013
ok thanks..

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by