extrapolate data to cross x axis
10 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
Star Strider
2022-1-18
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.
.
0 个评论
更多回答(2 个)
Max Heimann
2022-1-18
编辑:Max Heimann
2022-1-18
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!