Solving for two variable.
Afficher commentaires plus anciens
I have:
clearclc
x=[7.53*10^(-5) 3.17*10^(-4) 1.07*10^(-3) 3.75*10^(-3) 1.35*10^(-2) 4.45*10^(-2) 1.75*10^(-1) 5.86*10^(-1)];
y=[0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85];
but I need do find n and I0 from:
I = I0 * e^( (q*U)/(n*k*T) )
I already know q, U, k and T.
2 commentaires
Alan Stevens
le 10 Sep 2022
Modifié(e) : Alan Stevens
le 10 Sep 2022
What are the equivalents of x and y in your equation? Presumably, y represents I. What does x represent?
Sebastian
le 10 Sep 2022
Réponse acceptée
Plus de réponses (1)
I = [7.53*10^(-5) 3.17*10^(-4) 1.07*10^(-3) 3.75*10^(-3) 1.35*10^(-2) 4.45*10^(-2) 1.75*10^(-1) 5.86*10^(-1)];
U = [0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85];
q = 1.60*10^(-19);
k = 1.38*10^(-23) ;
T = 300;
value = q/(k*T);
fun = @(I0,n) I - I0 * exp( value * U / n );
p0 = [1 ; 10]; % Initial guess for I0 and n
options = optimset('TolX',1e-10,'TolFun',1e-10,'MaxFunEvals',100000,'MaxIter',100000);
sol = lsqnonlin(@(p)fun(p(1),p(2)),p0,[],[],options);
format long
I0 = sol(1)
n = sol(2)
hold on
plot(U,I,'o')
plot(U,I0 * exp( value * U / n ))
grid
hold off
4 commentaires
Sebastian
le 10 Sep 2022
I = [7.53*10^(-5) 3.17*10^(-4) 1.07*10^(-3) 3.75*10^(-3) 1.35*10^(-2) 4.45*10^(-2) 1.75*10^(-1) 5.86*10^(-1)];
U = [0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85];
q = 1.60*10^(-19);
k = 1.38*10^(-23) ;
T = 300;
value = q/(k*T);
fun = @(I0,n) I - I0 * exp( value * U / n );
p0 = [1 ; 10]; % Initial guess for I0 and n
options = optimset('TolX',1e-10,'TolFun',1e-10,'MaxFunEvals',100000,'MaxIter',100000);
sol = fminsearch(@(p)sum(fun(p(1),p(2)).^2),p0,options);
format long
I0 = sol(1)
n = sol(2)
hold on
plot(U,I,'o')
plot(U,I0 * exp( value * U / n ))
grid
hold off
No, you are wrong.
Applying log to your equation distorts the fitting.
You must fit I0*exp(value * U / n) against U to get unbiased estimates for your parameters.
Fitting log(I0) + value/n * U against log(U) only gives an approximation for I0 and n.
Catégories
En savoir plus sur Linear and Nonlinear Regression dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




