# using linear interpolation to find coefficients

19 views (last 30 days)
WILLBES BANDA on 28 May 2020
Answered: David Hill on 28 May 2020
Hi, i want to create a function that interpolates linearly to give me the coefficients. As an example, the function must take in AerodynamicData.Cm.BodyFlap (see below) and must use VehicleState to find the interpolated value of CmBodyFlap, which is the contribution that the body flap makes towards the aerodynamic coefficient named, Cm.
AerodynamicData.Cm.BodyFlap =
struct with fields:
deBF: [-11.7000 -5 0 5 10 16.3000 22.5000]
alpha: [-10 -5 0 5 10 15 20 25 30 35 40 45 50]
CmBodyFlap: [7×13 double]
VehicleState =
struct with fields:
alpha: 40
Mach: 5
deBF: 6
deSB: 0
deA: 0

Sulaymon Eshkabilov on 28 May 2020
Hi,
use polyfit(); e.g.
x = alpha; y = deBF; % then
Coeff= polyfit(x, y, N); % N=1 linear fit, N=2 second order polynomial fit, N=3 cubic polynomial, etc.
madhan ravi on 28 May 2020

David Hill on 28 May 2020
Make sure your matrix agrees with the meshgrid generated or change it to match.
[d,a]=meshgrid(AerodynamicData.Cm.BodyFlap.deBF,AerodynamicData.Cm.BodyFlap.alpha);
CmBodyFlap_interp=interp2(d,a,AerodynamicData.Cm.BodyFlap.CmBodyFlap,VehicleState.deBF,VehicleState.alpha);

### Categories

Find more on Interpolation in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!