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

Alan Stevens
Alan Stevens 2022년 9월 10일
편집: Alan Stevens 2022년 9월 10일
What are the equivalents of x and y in your equation? Presumably, y represents I. What does x represent?
Sebastian
Sebastian 2022년 9월 10일
x=I and y=U

댓글을 달려면 로그인하십시오.

 채택된 답변

Alan Stevens
Alan Stevens 2022년 9월 10일
편집: Alan Stevens 2022년 9월 10일

0 개 추천

In that case one way is to take logs of both sides to get:
log(I) = log(I0) + q/(n*k*T)*U
then do a best-fit straight line to the data (use log(x)) and get log(I0) from the intercept and q/(n*k*T) from the slope, from which yoiu can then get I0 and n.

댓글 수: 4

Sebastian
Sebastian 2022년 9월 10일
편집: Sebastian 2022년 9월 10일
I started with matlab yesterday so I need help with how I would do that?
clear
clc
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];
p=polyfit(x,y,1);
f=polyval(p,x);
plot(x,y,'o',x,f,'-');
Like this
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];
% You said x = I and U = y so
p=polyfit(y,log10(x),1);
f=polyval(p,y);
plot(y,log10(x),'o',y,f,'-'), grid
xlabel('U'),ylabel('logI')
% Intercept is p(2), slope is p(1)
I0 = 10^p(2);
q_on_nkT = p(1); % You need to rearrange this to get n, using
% your known values for q, k and T
disp(I0)
2.4861e-10
disp(q_on_nkT)
11.0383
Sebastian
Sebastian 2022년 9월 10일
편집: Sebastian 2022년 9월 10일
I have q = 1.60*10^(-19), k=1.38*10^(-23) and t=300
I get n = 1.5966
using n=(q*y)/(k*t*(log(x)-log(I0)))
the correct n is 1.521
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];
% You said x = I and U = y so
p=polyfit(y,log(x),1);
f=polyval(p,y);
figure(1)
plot(y,log(x),'o',y,f,'-'), grid
xlabel('U'),ylabel('logI')
% Intercept is p(2), slope is p(1)
I0 = exp(p(2));
q_on_nkT = p(1); % You need to rearrange this to get n, using
% your known values for q, k and T
q = 1.60*10^(-19);
k = 1.38*10^(-23);
T = 300;
n = q/(k*T*q_on_nkT);
disp(I0)
2.4861e-10
disp(n)
1.5206
figure(2)
plot(y,x,'o',y,I0*exp(q/(k*T)*y/n),'-'), grid
xlabel('U'),ylabel('I')

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Torsten
Torsten 2022년 9월 10일
편집: Torsten 2022년 9월 10일

0 개 추천

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);
Local minimum possible. lsqnonlin stopped because the final change in the sum of squares relative to its initial value is less than the value of the function tolerance.
format long
I0 = sol(1)
I0 =
4.840384083194344e-10
n = sol(2)
n =
1.570628124624527
hold on
plot(U,I,'o')
plot(U,I0 * exp( value * U / n ))
grid
hold off

댓글 수: 4

Sebastian
Sebastian 2022년 9월 10일
sorry, I don't have lsqnonlin
Torsten
Torsten 2022년 9월 10일
편집: Torsten 2022년 9월 10일
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)
I0 =
4.840330426445296e-10
n = sol(2)
n =
1.570627287586739
hold on
plot(U,I,'o')
plot(U,I0 * exp( value * U / n ))
grid
hold off
Sebastian
Sebastian 2022년 9월 10일
편집: Sebastian 2022년 9월 10일
I0 and n are both wrong.
I0 = 0.249*10^(-9)
and
n = 1.521
Torsten
Torsten 2022년 9월 10일
편집: Torsten 2022년 9월 10일
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.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

제품

릴리스

R2022a

질문:

2022년 9월 10일

편집:

2022년 9월 10일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by