extrapolate data to cross x axis

10 visualizaciones (últimos 30 días)
Asliddin Komilov
Asliddin Komilov el 18 de En. de 2022
Comentada: Star Strider el 18 de En. de 2022
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.

Respuesta aceptada

Star Strider
Star Strider el 18 de En. de 2022
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.
.

Más respuestas (2)

Max Heimann
Max Heimann el 18 de En. de 2022
Editada: Max Heimann el 18 de En. de 2022
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 el 18 de En. de 2022
sorry for the mess, I thought I have saved one variable. This is exactly what I needed.
thank you so much

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by