Error using scatteredInterpolant Sample values must be a double array.

43 ビュー (過去 30 日間)
Yuansen
Yuansen 2025 年 11 月 26 日 21:52
移動済み: Matt J 2025 年 11 月 27 日 14:25
Dear all,
I use griddata to interpolate one 2D data. The codes worked quite well half a year. But since today, it always showed an error "Error using scatteredInterpolant. Sample values must be a double array."
Can anyone do me a favor. Thanks a lot.
  5 件のコメント
Cris LaPierre
Cris LaPierre 2025 年 11 月 27 日 3:45
I can duplicate the error if I pass string values to scatteredinterpolant.
t = linspace(3/4*pi,2*pi,5)';
x = [3*cos(t); 2*cos(t); 0.7*cos(t)];
y = [3*sin(t); 2*sin(t); 0.7*sin(t)];
v = repelem([-0.5; 1.5; 2],length(t));
F = scatteredInterpolant(num2str(x),y,v);
Error using scatteredInterpolant
The input points must be a double array.
Try adding a str2double command to the values returned by your DAQ.
Walter Roberson
Walter Roberson 2025 年 11 月 27 日 6:05
I would use class() on Xf0, Yf0 and Z0 to check that they are in fact class double.

サインインしてコメントする。

採用された回答

Yuansen
Yuansen 2025 年 11 月 27 日 9:47
移動済み: Matt J 2025 年 11 月 27 日 14:25
thank you guys! You are all right, the DAQ in this time produced "single" type data. After I define them in "double", the problem was solved.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by