Interpolating data from a table

조회 수: 66 (최근 30일)
Rifat Ibn Azad Tanim
Rifat Ibn Azad Tanim 2020년 11월 12일
댓글: Cris LaPierre 2020년 11월 13일
Hello,
I'm trying to get the interpolated Cl and Cd from this table. For example, say for -173.2 AOA, I want to find out the corresponding Cl & Cd. The file here is an excel file and I have imported them into matlab and named the variable naca which is the size of 395*4. I have also tried interp1 function to interpolate.
For example,
I tried, interp1(naca.AOA, naca.Cl, -173.2);
The error it gives out is- "Error using griddedInterpolant
The sample points must be finite.
Error in interp1 (line 170)
F = griddedInterpolant(X,V(:,1),method);"
Any help regarding this would be really appreciated.

답변 (1개)

Cris LaPierre
Cris LaPierre 2020년 11월 12일
편집: Cris LaPierre 2020년 11월 12일
Works here. Perhaps try clearing your workspace and then rerunning your code.
AOA = (-180:1:-167)';
Cl = sort(rand(size(AOA))-0.15);
Cd = sort(rand(size(AOA)));
naca=table(AOA,Cl,Cd)
naca = 14x3 table
AOA Cl Cd ____ __________ ________ -180 -0.14264 0.068609 -179 -0.10548 0.10965 -178 -0.05547 0.12092 -177 -0.051742 0.18885 -176 -0.0049866 0.49856 -175 0.027617 0.50889 -174 0.0449 0.5568 -173 0.11746 0.62728 -172 0.14203 0.67654 -171 0.29605 0.68496 -170 0.3297 0.87587 -169 0.75624 0.88073 -168 0.77464 0.91418 -167 0.81968 0.91765
interp1(naca.AOA,naca.Cl,-173.2)
ans = 0.1030
  댓글 수: 2
Rifat Ibn Azad Tanim
Rifat Ibn Azad Tanim 2020년 11월 12일
Hi,
Thank you so much for replying. Turns out I couldn't do it because I had NaNs in the table. I had to get rid of the NaNs to get it working. Any idea as to how to get around those NaNs? Anyway, for now, it's working. Thank you very much again.
Cris LaPierre
Cris LaPierre 2020년 11월 13일
You could use the rmmissing and/or fillmissing functions to handle NaNs.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by