how to use interp1() function with half data

조회 수: 4 (최근 30일)
li
li 2025년 6월 5일
댓글: Matt J 2025년 6월 5일
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?

채택된 답변

Sam Chak
Sam Chak 2025년 6월 5일
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
li
li 2025년 6월 5일
Great! I had tried your method,it works.
Matt J
Matt J 2025년 6월 5일
@li If so, please Accept-click the answer.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by