Error using matlab.int​ernal.math​.interp1 The sample points must be finite.

22 visualizaciones (últimos 30 días)
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
huiting wang
huiting wang el 22 de Abr. de 2022
There is something strange, my collegue use the same codes, same version of MATLAB, but he got no problem,
but when I ran the script on my computer, it just gets errors
huiting wang
huiting wang el 26 de Abr. de 2022
x is a 1000*50 double, v is a 1000*50 double, and xq is a 20*50 double, the data has no problem, I use x(:,1),v(:,1) and xq(:1) to do a interp1 function call, and there is no error. But when I ran my script, it show errors again
my test is here
K>>testx = x(:,1);
K>> testv = v(:,1);
K>> testxq = xq(:,1);
K>> interp1(testx,testv,testxq)
ans =
307.6069
307.0587
306.5055
305.9470
305.3835
304.8147
304.2408
303.6617
303.0773
302.4877
301.8929
301.2928
300.6874
300.0766
299.4607
298.8394
298.2129
297.5811
296.9440
296.3017
ran my script, the error is:
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 783)
tOut(:,i) = interp1(x(:,i),v(:,i),xq(:,i));
Error in at_fdplus.evap.plate_fin.PlateFinHE/calcBlock (line 250)
t.new.cf = CF.calcMoistHeatCool(mDot_CF,Q.wall,'Cooling',CF.p(1,:),CF.t(1,:),CF.X_tot(1,:));
Error in TestPlateFinHE (line 25)
Q.AKG = HE_AKG.calcBlock(FIN_HF,FIN_CF,mDot.hf,mDot.cf);

Iniciar sesión para comentar.

Respuesta aceptada

Steven Lord
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
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.
huiting wang
huiting wang el 27 de Abr. de 2022
the call of intterp1 function is indead a for-loop,but the value of x,v,xq are already defined, all value in these three arrays are 8 doubles, the first row of x is 0, x,v,xq are not calculated in a loop
part of data:
x = [0 0 0 0 ......
-33.4436754520186 -33.6320781597295 -33.8204638769074 -34.0088325974662 .....
-66.8773808240819 -67.2540736138778 -67.6307318006384 -68.0073553721683 .....
-100.301123027146 -100.865993391092 -101.430810918744 -101.995575591848 .....
-133.714908970212 -134.467844517515 -135.220708375837 -135.973500521303 ......
........
] x is 1000*50 double
v = [308.150000000000 308.150000000000 308.150000000000 308.150000000000 308.150000000000 ....
308.132735976222 308.132638705915 308.132541444217 308.132444191131 308.132346946660 ....
308.115471952443 308.115277411830 308.115082888434 308.114888382262 308.114693893320 ....
308.098207928665 308.097916117745 308.097624332651 308.097332573393 308.097040839980 .....
308.080943904887 308.080554823660 308.080165776868 308.079776764524 308.079387786640 .....
308.063679881109 308.063193529576 308.062707221086 308.062220955655 308.061734733300 .....
308.046415857330 308.045832235491 308.045248665303 308.044665146786 308.044081679960 .....
.....] v is 1000*50 double
xq = [-1047.32884340479 -1053.22978509923 -1059.13020454832 -1065.03010155478 ....
-2094.65768680958 -2106.45957019847 -2118.26040909665 -2130.06020310956 ....
-3141.98653021437 -3159.68935529770 -3177.39061364497 -3195.09030466434 ....
-4189.31537361916 -4212.91914039693 -4236.52081819330 -4260.12040621912 ....
-5236.64421702395 -5266.14892549617 -5295.65102274162 -5325.15050777390 ....
-6283.97306042875 -6319.37871059540 -6354.78122728994 -6390.18060932868 ...
-7331.30190383354 -7372.60849569464 -7413.91143183827 -7455.21071088346 ....
....] xq is 20*50 double
I find no infinite data in them

Iniciar sesión para comentar.

Más respuestas (1)

huiting wang
huiting wang el 27 de Abr. de 2022
I stilled don't know the reason of error, but the bug is fixed magically, I'm not sure what I did solved this problem, but thank you all guys for your valuable advice!
  2 comentarios
凡奇
凡奇 el 12 de Nov. de 2022
I‘m also getting the same error, but I don't know how to solve it.......
Bob photonics
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

Iniciar sesión para comentar.

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by