how to use interp1() function with half data

4 Ansichten (letzte 30 Tage)
li
li am 5 Jun. 2025
Kommentiert: Matt J am 5 Jun. 2025
x=half(0:5);
y=x.^2;
interp1(x,y,5)
Error using matlab.internal.math.interp1
Sample values must be of type double or single.
Error in interp1 (line 188)
VqLite = matlab.internal.math.interp1(X,V,method,method,Xqcol);
How to use interpolation with half or even shorter types?

Akzeptierte Antwort

Sam Chak
Sam Chak am 5 Jun. 2025
Hi @li, If you double the data, it works.
x=half(0:5)
x = 1×6 half row vector 0 1 2 3 4 5
y=x.^2
y = 1×6 half row vector 0 1 4 9 16 25
interp1(double(x), double(y), 5)
ans = 25
  4 Kommentare
li
li am 5 Jun. 2025
Great! I had tried your method,it works.
Matt J
Matt J am 5 Jun. 2025
@li If so, please Accept-click the answer.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by