Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how corrige an error in the program using vpasolve

1 回表示 (過去 30 日間)
khouloud abiedh
khouloud abiedh 2018 年 8 月 14 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
i write this code to resolve two non linear equation ,but there are an error which i can't corrige it to obtain the last graph who can help me thank you in advance .
%% defining constants
sigma = 30*10^-3;%eV
deltaE = -73e-3;%eV
E0 = 1.26;%eV Ea = E0+16e-3; tautr=0.022 ; taur=800; ; Kb = 8.617*10^-5;%eV/K theta = 270; %K alfa = 0.00048;%eV/K T = 0:10:300;
X=zeros(size(T)); E1=zeros(size(T)); E2 = zeros(size(T));
%% resoudre l'equation et trouver x syms x
for i=1:numel(T)
E1(i) = E0 -( alfa*T(i)^2)/(theta+T(i));
X(i) = vpasolve(((sigma/(Kb*T(i)))^2-x)*(taur/tautr)*exp(deltaE/(Kb*T(i)))-x*exp(x)==0,x);
E2(i) = E0 -(alfa*T(i)^2)/(theta + T(i))-X(i)*Kb*T(i);
a(i)=X(i)*Kb*T(i);
end
%% resoudre l'equation et trouver X1
x1 = zeros(size(T)); a = zeros(size(T)); b = zeros(size(T)); c = zeros(size(T)); d = zeros(size(T));
h=2*(sigma)^2;
for i=1:numel(T) a(i)=X(i)*Kb*T(i); b(i)=exp((-a(i)^2)/(2*(sigma)^2)); c(i)=exp((E0-a(i)-Ea)/(Kb*T(i)))+(tautr/taur); d(i)=0.5*(b(i)/c(i)); end syms x1
for i=1:numel(T)
X1(i)= vpasolve((exp((x1-E0)^2/h))/(exp((x1-Ea)/(Kb*T(i))) + (tautr/taur))- d(i)==0,x1);
end %%
figure(1) plot(T,E1,'r.') title('E1')
figure(2) plot(T,E2,'b') title('E2') hold on plot(T,E1,'r') hold on;
figure(3) plot(T,X,'k.','Markersize',15) title('X');
figure (4) plot(T,a,'k');
figure(5) plot(T,X1,'g'); the error is
  2 件のコメント
Walter Roberson
Walter Roberson 2018 年 8 月 14 日
You could get that error if the vpasolve was not able to find a solution. It would return empty in that case. You should assign the output to a temporary variable and then check the results and store something like nan if there was no result.
khouloud abiedh
khouloud abiedh 2018 年 8 月 14 日
thank you for your comment. im debutant in matlab i can't corrige it because i don't know how .can you help me please.

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by