I have a set of data obtained for the I-V characteristics of an LED.
0.005 -0.004
0.053 -0.003
0.101 -0.003
0.153 -0.002
0.201 -0.002
0.252 -0.002
0.303 -0.004
0.354 -0.004
0.403 -0.004
0.454 -0.003
0.503 -0.003
0.554 -0.003
0.603 -0.003
0.654 -0.003
0.702 -0.003
0.753 -0.002
0.802 -0.002
0.853 -0.002
0.902 -0.002
0.953 -0.001
1.002 -0.002
1.050 -0.001
1.104 -0.004
1.153 -0.004
1.204 -0.004
1.253 -0.004
1.304 -0.004
1.353 -0.003
1.404 -0.003
1.452 -0.003
1.503 -0.003
1.552 -0.002
1.603 -0.003
1.652 -0.002
1.703 -0.002
1.752 -0.002
1.803 -0.002
1.851 -0.001
1.903 -0.002
1.954 -0.004
2.005 -0.004
2.054 -0.004
2.102 -0.003
2.153 -0.003
2.202 -0.003
2.253 -0.003
2.301 -0.002
2.352 -0.001
2.398 0.001
2.442 0.008
2.475 0.024
2.501 0.050
2.519 0.081
2.533 0.118
2.544 0.156
2.552 0.199
2.560 0.240
2.567 0.284
2.573 0.327
2.578 0.373
2.583 0.417
2.587 0.462
2.591 0.509
2.595 0.554
2.599 0.601
2.602 0.647
2.606 0.694
2.609 0.740
2.611 0.789
2.615 0.835
2.617 0.883
2.620 0.929
2.622 0.978
2.625 1.025
2.627 1.073
2.630 1.120
2.632 1.169
2.635 1.215
2.637 1.264
2.639 1.311
2.641 1.358
2.643 1.407
2.645 1.454
2.648 1.503
2.649 1.550
2.652 1.599
2.653 1.646
2.655 1.696
2.657 1.743
2.658 1.792
2.660 1.839
2.662 1.889
2.664 1.936
2.666 1.985
2.667 2.033
2.668 2.082
2.670 2.129
2.672 2.179
2.674 2.226
2.675 2.276
2.676 2.324
How do I fit only a range of values out of this data to a linear function? I am able to achieve this by saving the required range of data as a separate file linear-07.txt
and then fitting this set of values to the function f(x).
set term svg
set output 'blue.svg'
set term svg
set output 'blue.svg'
f(x) = a*x + b
fit f(x) 'linear-07.txt' via a,b
plot[][-1:3] '07-B.txt' pt 7, f(x)
However this seems to be exhausting. Is there an alternate method to this?
Also, How do I obtain the x-value (of the fit function) corresponding to f(x)=0?
fit
supports ranges likeplot
, e.g.fit [0:0.5] f(x) 'file' via a,b
. Thea
andb
values are saved asa
andb
, try printing them after fitting:print a, b
$\endgroup$ – Thor Apr 28 '19 at 15:04print -b/a
to obtain the required value? $\endgroup$ – kJd47 Apr 28 '19 at 16:24