How to interpolate a matrix ?

Hello everyone.I have a question about an matrix.I want to a interpolation in M(10X2 double)' datas.And I want to obtain the N(9X2) matrix.Here you can see the example
time step variables time step variables
M=[ 3.2 5 N= [4 ...?
4.1 4 5 ...?
5.6 3 6 ...?
6.7 2 7 ...?
7.5 1 8 ...?
8.4 3 9 ...?
9.3 2 10 ...?
10.5 5 11 ...?
11.4 2 12 ...?]
12 6]
Thanks for your answer !!!

 Risposta accettata

Try this —
M=[ 3.2 5
4.1 4
5.6 3
6.7 2
7.5 1
8.4 3
9.3 2
10.5 5
11.4 2
12 6]
M = 10×2
3.2000 5.0000 4.1000 4.0000 5.6000 3.0000 6.7000 2.0000 7.5000 1.0000 8.4000 3.0000 9.3000 2.0000 10.5000 5.0000 11.4000 2.0000 12.0000 6.0000
N = [4; 5; 6; 7; 8; 9; 10; 11; 12];
N2 = interp1(M(:,1),M(:,2),N)
N2 = 9×1
4.1111 3.4000 2.6364 1.6250 2.1111 2.3333 3.7500 3.3333 6.0000
N = [N N2]
N = 9×2
4.0000 4.1111 5.0000 3.4000 6.0000 2.6364 7.0000 1.6250 8.0000 2.1111 9.0000 2.3333 10.0000 3.7500 11.0000 3.3333 12.0000 6.0000
See the documentation for interp1 for details.
.

4 Commenti

Thank you so much,but I have a 3015X1 matrix.When ı this situation how can I define N sir ? I forgot to put this situation.Sorry :/
My pleasure!
I created ‘N’ using the original ‘N(:,1)’ as the first column, and the interpolated values as the (second) ‘N(:,2)’ column, as described in the original post.
Do the same with your (3015x1) vector.
Thank you so much!
As always, my pleasure!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Interpolation in Centro assistenza e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by