extrapolate data to cross x axis
    9 views (last 30 days)
  
       Show older comments
    
    Asliddin Komilov
 on 18 Jan 2022
  
    
    
    
    
    Commented: Star Strider
      
      
 on 18 Jan 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.
0 Comments
Accepted Answer
  Star Strider
      
      
 on 18 Jan 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.  
.
0 Comments
More Answers (2)
  Max Heimann
      
 on 18 Jan 2022
        
      Edited: Max Heimann
      
 on 18 Jan 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.
0 Comments
See Also
Categories
				Find more on Fit Postprocessing in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

