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!