0
$\begingroup$

Please can anybody help me to get a linear, and quadratic fit. I have a line from numerical calculations (Refs), and I want to fit the data(max) with (Refs). I tried linear fit but I have a problem when I use it for two variables and also for the quadratic fit.

I used fl[x_, y_] = Normal@LinearModelFit[tab, a1r (y - y0) + b1r (x - x0), {a1r, b1r}, {x, y}] , and x0=0.3459; y0=0.4478, but it doesn't work.

Or is there a way to use this (y-y0)=m(x-x0), m is the slope of the numerical line(Refs) to make fitting.

my data is many, I don't know how to post all, I just post some.

  tab= {{0.025, 0.075, -0.0129036}, {0.0255, 0.075, -0.00949092}, {0.026, 
 0.075, -0.00607024}, {0.0265, 0.075, -0.00264156}, {0.027, 0.075, 
 0.000795063}, {0.0275, 0.075, 0.00423958}, {0.028, 0.075, 
 0.00769193}, {0.0285, 0.075, 0.0111521}, {0.029, 0.075, 
 0.01462}, {0.0295, 0.075, 0.0180955}, {0.03, 0.075, 
 0.0215787}, {0.025, 0.0755, -0.0131653}, {0.0255, 
 0.0755, -0.00975679}, {0.026, 0.0755, -0.00634031}, {0.0265, 
 0.0755, -0.00291584}, {0.027, 0.0755, 0.000516539}, {0.0275, 0.0755,
 0.00395679}, {0.028, 0.0755, 0.00740485}, {0.0285, 0.0755, 
 0.0108607}, {0.029, 0.0755, 0.0143242}, {0.0295, 0.0755, 
 0.0177954}, {0.03, 0.0755, 0.0212742}, ......}

  Refs = ListContourPlot[tab, FrameLabel -> {"x", "y"}, 
    ContourStyle -> Blue  , ContourShading -> False, Contours -> 1]

  max = {{0.023919999999999997`, 0.05784`}, {0.023919999999999997`, 
0.05824000000000001`}, {0.024319999999999998`, 
0.058640000000000005`}, {0.024319999999999998`, 
0.05904000000000001`}, {0.024319999999999998`, 
0.05944000000000001`}, ...}

  x0=0.3459; 
  y0=0.4478
 x = max[[All, 1]];
 y = max[[All, 2]];
    p = ListLinePlot[max, PlotRange -> {{0.025`, 0.03}, {0.075, 0.08`}}, 
   BaseStyle -> {Red}]

 Show[Refs, p]

Thanks in advance.

$\endgroup$
  • 2
    $\begingroup$ Would you add your code for the linear fit that you performed? $\endgroup$ – JimB Mar 6 '18 at 15:46
  • $\begingroup$ I want to make a fit between the line I got from (max) and the numerical line (Refs). $\endgroup$ – Ghady Mar 6 '18 at 15:53
  • $\begingroup$ Or , is there a way to get the slope for data(tab) to generate a new data (x,y) for data(max) to fit with the original line Refs. $\endgroup$ – Ghady Mar 6 '18 at 16:02
  • $\begingroup$ What function did you use to try to get a linear (or quadratic) fit? $\endgroup$ – chuy Mar 6 '18 at 16:33
  • $\begingroup$ f(x,y)=ax+by or in case using the slop y = mx $\endgroup$ – Ghady Mar 6 '18 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.