필터 지우기
필터 지우기

Extrapolate using half the slope than in original data

조회 수: 5 (최근 30일)
SChow
SChow 2020년 6월 27일
댓글: SChow 2020년 6월 27일
I have a set of 21 X,Y poinst which I intend to extrapolate by using slope (rate of change)= 1/2 than that is observed in the original X,Y dataset.
The code thus far
Xext=22:82; (trying to extrapolate until limit= 82)
c = polyfit((X(end-8:end)), (Y(end-8:end)),1); % linear fit based on the last 8 points
c1=[c(1)/2, c(2)];%%making slope 1/2 of the original X,Y dataset
Yext = polyval(c1,Xext);
%%plotting to obtain a figure that shows the first 21 points changing at the observed rate and the next extrapolated to change at 1/2 its rate
Xn=[X,Xextrap(9:end)];
Yn=[Y,Yextrap(9:end)];
plot(Xn,Yn)
This makes a bit of an unwated hump where the extrapolation begins (see attached)
Any help is greatly appreciated

채택된 답변

dpb
dpb 2020년 6월 27일
You've got to match the two at the breakpoint...w/o data so didn't use but the endpoints to roughly match your figure...
x=[1 20]; y=[695 420]; % about what the fitted line looks to be
b1=polyfit(x,y,1); % first section coefficients
b2=[b1(1)/2 polyval(b1,x(end))-b1(1)/2*x(end)]; % solve for intercept to match at breakpoint x
Above yields for a set of data after the breakpoint as well as before...
plot(x,polyval(b1,x),'b-', ... % first segment uses b1 coefficients while
[0 80]+x(end),polyval(b2,[0 80]+x(end)),'r-') % at/after uses second
NB: the endpoints match this way.
NB SECOND: Above uses x from origin for both sections and requires using the proper coefficient array for the two sections. Alternatively, one could use a new origin at the end of first segment depending on the application. Slope would be same but the intercept for second would then be yfit(x(end)).

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by