How to interpolate a matrix ?

6 views (last 30 days)
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 !!!

Accepted Answer

Star Strider
Star Strider on 9 May 2021
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 Comments
Star Strider
Star Strider on 9 May 2021
As always, my pleasure!

Sign in to comment.

More Answers (0)

Categories

Find more on Interpolation in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!