# curve fitting for the optimal value of a constant

4 views (last 30 days)
pooja sudha on 8 Oct 2020
Edited: KSSV on 8 Oct 2020
Hey here, I am trying to find the value of k(unknown constant) and for that I have collected data points from a curve and then fit into other(as attached). I had found the result i.e., 0.1300 but it isn't matching with the result which is 1.
So, can anybody tell me if there is any mistake.
Thankyou
r=0:1*10^-9:50*10^-9;
l=50*10^-9;
e=1.6*10^-19;
V=((1.44).*exp(3.257*((r./l).^2)).*besselk(0,(3.257*((r./l).^2))))./(e.^2);
R=r/l;
plot(R,V)
h=findobj(gca, 'Type', 'line');
R=h.XData
V=h.YData
k0 = rand()*10;
R=[0.0200,0.0400,0.0600,0.0800,0.1000,0.1200,0.1400,0.1600,0.1800,0.2000,0.2200,0.2400,0.2600,0.2800,0.3000,0.3200,0.3400,0.3600,0.3800,0.4000,0.4200,0.4400,0.4600,0.4800,0.5000,0.5200,0.5400,0.5600,0.5800,0.6000,0.6200,0.6400,0.6600,0.6800,0.7000,0.7200,0.7400,0.7600,0.7800,0.8000,0.8200,0.8400,0.8600,0.8800,0.9000,0.9200,0.9400,0.9600,0.9800,1.0000];
V=1.0e+38*[3.8070,3.0381,2.5965,2.2900,2.0580,1.8734,1.7216,1.5937,1.4841,1.3888,1.3051,1.2309,1.1646,1.1050,1.0510,1.0020,0.9572,0.9161,0.8783,0.8433,0.8110,0.7810,0.7530,0.7269,0.7025,0.6796,0.6581,0.6379,0.6189,0.6009,0.5839,0.5678,0.5525,0.5380,0.5243,0.5111,0.4987,0.4868,0.4754,0.4645,0.4541,0.4442,0.4346,0.4255,0.4167,0.4083,0.4002,0.3924,0.3849,0.3777];
bestk = lsqcurvefit( @(k,R)(1./((sqrt((k.^2)+(R.^2))).*(e.^2))), k0, R, V)

### Categories

Find more on Least Squares 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!

Translated by