Azzera filtri
Azzera filtri

How do I extrapolate the curve to x = -5 and x = 25 using an appropriate extrapolation approximation?

1 visualizzazione (ultimi 30 giorni)
%This is what I have so far, and I am to plot the extrapolated data points once I get it correctly. Thanks for the help!
%The file "curves.xlsx" is just a 21x2 matrix in excel.
curve = xlsread('curve.xlsx');
day = curve(:,1);
hairBalls = curve(:,2);
steps = (0:.2:20);
interSpline = interp1(day,hairBalls,steps,'spline');
extrapoSpline = interp1(day,hairBalls,steps,'spline','extrap');
plot(day, hairBalls,'ko',steps,interSpline,'rx:');
  3 Commenti
Stephen23
Stephen23 il 21 Set 2017
@Snooping Poppet: it is not appreciated when you edit away the text of your question. Imagine if everyone did that, then this entire forum would be useless for anyone else as it would only consist of thousands of threads all reading "This post was taken down". Would you find that useful?
By deleting your question you unilaterally decided that Star Stider's volunteered time helping you shall not be useful to anyone else. Does Star Strider get a say in this decision? Do you think this is why we volunteers come here and write our advice and comments?
If you want a consulting service then you will find plenty of them on them internet. This is a community forum with answers provided by volunteers.

Accedi per commentare.

Risposte (1)

Star Strider
Star Strider il 18 Ott 2016
Modificato: Star Strider il 18 Ott 2016
Extrapolation to this extent is hazardous. You may be assuming much more about the data outside the region-of-fit than are appropriate.
That aside, the way to extrapolate it from -5 to +25 is to add those values to your ‘query’ vector:
extrapoSpline = interp1(day,hairBalls, [-5, steps, 25], 'spline','extrap');
If you want it to extrapolate continuously to include those limits, change your interpolation ‘query’ vector to include them as limits:
steps2 = (-5:0.2:25);
extrapoSpline = interp1(day,hairBalls,steps2,'spline','extrap');
Good luck!
  4 Commenti
Star Strider
Star Strider il 19 Ott 2016
This works for me:
steps2 = (-5:0.2:25);
extrapoSpline2 = interp1(day,hairBalls,steps2,'spline','extrap');
figure(2)
plot(day, hairBalls,'ko', steps2,extrapoSpline2,'gx:')
If it doesn’t produce the result you are expecting (and I have no idea what they are), it serves to illustrate the hazards of extrapolating beyond the region-of-fit. Consider a different extrapolation method (such as 'linear' or 'pchip'), or perhaps a simple linear fit to get the result you want.
For example:
B = [ones(size(day)) day]\hairBalls;
LinearFit = [[1; 1] [-5; 25]]*B;
figure(3)
plot(day, hairBalls,'ko', [-5 25],LinearFit,'--g')
The polyfit and polyval functions also provide different fitting and extrapolation options you may want to explore.
What you want and what the relevant mathematics can provide may not exactly match.

Accedi per commentare.

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Tag

Non è stata ancora inserito alcun tag.

Community Treasure Hunt

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

Start Hunting!

Translated by