Error using matlab.internal.math.interp1 The sample points must be finite.
23 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
huiting wang
le 22 Avr 2022
Commenté : Bob photonics
le 14 Fév 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 commentaires
Réponse acceptée
Steven Lord
le 26 Avr 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 commentaires
Steven Lord
le 27 Avr 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.
Plus de réponses (1)
huiting wang
le 27 Avr 2022
2 commentaires
Bob photonics
le 14 Fév 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
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!