Extending Polyfit to Specified Y Value
Show older comments
Hi guys,
I am currently plotting a graph depicting the power required for a helicopter to hover at 1000 feet (PStd) compared to its gross takeoff weight (GTOW). I have used polyfit and polyval to plot a curve fitting through my found data but need to extend the curve to a known Y value (minimum takeoff weight of the helicopter - MinTOWD) so that I can extrapolate the power required to hover at that value. The current curve ends at 16670 (the lowest weight in my gathered data) but need to extend it to 10475.
%Import and Sort Data
data = xlsread('\\nask.man.ac.uk\home$\ClimbPower.xlsx','Sheet1');
GTOW = data(1:length(data),1);
PStd = data(1:length(data),2);
%Minimum Takeoff Weight
MinTOWD = 10475;
%Plot Data and Curve Fit
figure
plot(PStd,GTOW,'ks');
hold on
FitStd = polyfit(PStd,GTOW,3);
PolyStd = polyval(FitStd,PStd);
plot(PStd,PolyStd,'k--');
xlabel ('Power (kW)')
ylabel ('Gross Takeoff Weight (kg)')
title ('Power Required to Hover at 1000 Feet for Given Gross Takeoff Weight')
grid minor
Thanks in advance.
Jack
Answers (1)
Adam Danz
on 13 Mar 2019
0 votes
After you compute the coefficients using polyfit(), you can use a different set of x values in polyval() to compute a new set of y values. The problem is, you don't know how far out you need to extend x in order to get to your desired y value. You can either solve the polynomial for y (not easy, see below) or you can just extend x in polyval() far enough that it will cover your desired y value. The 2nd option is a lot easier but might not result in an exact x value that precisely results in your desired y value. But depending on your x values in polyval(), you could get very close.
You're computing the 3rd degree polynomial which is (p are your coefficients)
y = p(1)*x^3 + p(2)*x^2 + p(3)*x + p(4)
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!