I have two vectors :
x= [1 2 3 4 5 6]
and
y=[2.3 4.3 5 4.7 9 12]
and i need to find the value of y in x = 3.5

댓글 수: 6

James Tursa
James Tursa 2018년 2월 1일
Is this an interpolation question? Or ...?
Dombrovschi Andrei
Dombrovschi Andrei 2018년 2월 1일
nope ...
Rik
Rik 2018년 2월 1일
Then what is it?
Dombrovschi Andrei
Dombrovschi Andrei 2018년 2월 1일
I want to see the value of y in time x = 3.5 per graph
Dombrovschi Andrei
Dombrovschi Andrei 2018년 2월 1일
편집: per isakson 2018년 2월 1일
x= [1 2 3 4 5 6]
y=[2.3 4.3 5 4.7 9 12]
figure
plot(x,y,'r-')
value = xx==3.5(find(y));
hold on
plot(3.5,value,'r*')
Isn't that interpolation
>> interp1( x, y, 3.5 )
ans =
4.8500

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

답변 (2개)

Star Strider
Star Strider 2018년 2월 1일

0 개 추천

It is an interpolation, regardless of the method you want to use. There are likely several ways to do this.
Using interp1:
x = [1 2 3 4 5 6];
y = [2.3 4.3 5 4.7 9 12];
idx = find(x <= 3.5, 1, 'last');
yi = interp1(x(idx:idx+1), y(idx:idx+1), 3.5, 'linear')
yi =
4.8500
If you want to use the 'previous', 'next', or 'nearest' methods instead of 'linear', the results are 5, 4.7, and 4.7 respectively.
Dombrovschi Andrei
Dombrovschi Andrei 2018년 2월 1일

0 개 추천

thanks guys !

카테고리

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

태그

질문:

2018년 2월 1일

댓글:

2018년 2월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by