Error using matlab.internal.math.interp1 The sample points must be finite.
22 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
huiting wang
el 22 de Abr. de 2022
Comentada: Bob photonics
el 14 de Feb. de 2025
when I ran a script,
for i=1:sz(2)
tOut(:,i) = interp1(x(:,i),v(:,i),xq(:,i));
end
I got those errors
Error using matlab.internal.math.interp1
The sample points must be finite.
Error in interp1 (line 188)
VqLite = matlab.internal.math.interp1(X,V,method,method,Xqcol);
Error in coolprop_tab.MoistAir.calcMoistHeatCool (line 782)
tOut(:,i) = interp1(x(:,i),v(:,i),xq(:,i));
4 comentarios
Respuesta aceptada
Steven Lord
el 26 de Abr. de 2022
Error in coolprop_tab.MoistAir.calcMoistHeatCool (line 783)
tOut(:,i) = interp1(x(:,i),v(:,i),xq(:,i));
Set a breakpoint on line 783 of coolprop_tab.MoistAir.calcMoistHeatCool or set an error breakpoint (which doesn't require you to specify a line number.) Then run your code. Once MATLAB stops at the breakpoint, show us what these commands return:
locationOfNonfiniteX = find(~isfinite(x(:, i)))
locationOfNonfiniteV = find(~isfinite(v(:, i)))
locationOfNonfiniteXq = find(~isfinite(xq(:, i)))
At least one of those variables should be non-empty. Look at the values of x, v, and/or xq at those locations and you should find they are either Inf or NaN. Once you've identified the problem locations, you'll need to work your way back through your code to determine where and why the nonfinite values were introduced.
Inf likely came in from an overflow; if you multiplied an extremely large number by another number the result could be greater than realmax.
NaN likely would come from dividing 0 by 0 or subtracting Inf from Inf. There are other ways that you can get a NaN but those are two of the more common.
3 comentarios
Steven Lord
el 27 de Abr. de 2022
I'm guessing this code is in a loop. If so, keep running until you find the column of x, v, and/or xq that has the nonfinite data.
Más respuestas (1)
huiting wang
el 27 de Abr. de 2022
2 comentarios
Bob photonics
el 14 de Feb. de 2025
Use this code to look for NaN/Inf values in your matrix/array/table
~isfinite(YourMatrix) %if it shows a logical 1 then you've a NaN/Inf value
[row, col] = find(~isfinite(YourMatrix)) % will show you all the locations where you have NaN values
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!