I have this curve and need to extrapolate it so both ends cross x axis, I have used Vq = INTERP1(X,V,Xq,'linear",'extrap') and tried other 'method's but it did not look "good".
any suggestions how to do it nicely? thanks.

 채택된 답변

Star Strider
Star Strider 2022년 1월 18일

0 개 추천

There are 19 variables in that .mat file. I have no idea which ones are to be extrapolated, so I took a wild guess on two of them.
Try these —
LD = load('QTHLS.mat');
figure
plot(LD.MHLSx, LD.MHLS)
grid
MHLS1i = interp1(LD.MHLS(1:10), LD.MHLSx(1:10), 0, 'linear','extrap')
p = polyfit(LD.MHLSx(end-9:end), LD.MHLS(end-9:end),1)
MHLS2i = -p(2)/p(1)
hold on
plot([MHLS1i, LD.MHLSx(1)], [0 LD.MHLS(1)], '-r')
plot([MHLS2i, LD.MHLSx(end)], [0 LD.MHLS(end)], '-r')
hold off
figure
plot(LD.XLSx, LD.XLS)
grid
XLS1i = interp1(LD.XLS(1:10), LD.XLSx(1:10), 0, 'linear','extrap')
p = polyfit(LD.XLSx(end-9:end), LD.XLS(end-9:end),1)
XLS2i = -p(2)/p(1)
hold on
plot([XLS1i, LD.XLSx(1)], [0 LD.XLS(1)], '-r')
plot([XLS2i, LD.XLSx(end)], [0 LD.XLS(end)], '-r')
hold off
The online Run feature does not work well with .mat files, so I did this offline.
They also demonstratae two diferent methods of doing the extrapolation.
.

추가 답변 (2개)

Max Heimann
Max Heimann 2022년 1월 18일
편집: Max Heimann 2022년 1월 18일

0 개 추천

In order for this question to be answered you should define what you mean by "nice". Unfortunately your code sample is not runable with the given workspace. But if it were it would still be unclear what would need to change for you to have an acceptable curve.
You could try polyfit and polyval to generate a polynomial which matches your data and then extrapolate by evaluating it outside of your datapoints. This works best if you have some idea how your curve should look like outside of your existing datapoints.
Asliddin Komilov
Asliddin Komilov 2022년 1월 18일

0 개 추천

sorry for the mess, I thought I have saved one variable. This is exactly what I needed.
thank you so much

카테고리

도움말 센터File Exchange에서 Fit Postprocessing에 대해 자세히 알아보기

태그

질문:

2022년 1월 18일

댓글:

2022년 1월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by