Resample a matrix with a defined interval

조회 수: 4 (최근 30일)
Jules Ray
Jules Ray 2013년 11월 5일
댓글: Jules Ray 2013년 11월 5일
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

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 5일
편집: Azzi Abdelmalek 2013년 11월 5일
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
Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 5일
편집: Azzi Abdelmalek 2013년 11월 5일
Your data in A are sorted in descending order, -13>-13.2
Jules Ray
Jules Ray 2013년 11월 5일
ok thanks..

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by