Hello guys , please help me ! I
Afficher commentaires plus anciens
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 commentaires
James Tursa
le 1 Fév 2018
Is this an interpolation question? Or ...?
Dombrovschi Andrei
le 1 Fév 2018
Rik
le 1 Fév 2018
Then what is it?
Dombrovschi Andrei
le 1 Fév 2018
Dombrovschi Andrei
le 1 Fév 2018
Modifié(e) : per isakson
le 1 Fév 2018
per isakson
le 1 Fév 2018
Isn't that interpolation
>> interp1( x, y, 3.5 )
ans =
4.8500
Réponses (2)
Star Strider
le 1 Fév 2018
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.
Catégories
En savoir plus sur Interpolation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
