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 !!!

 채택된 답변

Star Strider
Star Strider 2021년 5월 9일

0 개 추천

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

Omer Utku Altindag
Omer Utku Altindag 2021년 5월 9일
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 :/
Star Strider
Star Strider 2021년 5월 9일
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.
Omer Utku Altindag
Omer Utku Altindag 2021년 5월 9일
Thank you so much!
Star Strider
Star Strider 2021년 5월 9일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Interpolation에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by