Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

how corrige an error in the program using vpasolve

1 visualizzazione (ultimi 30 giorni)
khouloud abiedh
khouloud abiedh il 14 Ago 2018
Chiuso: MATLAB Answer Bot il 20 Ago 2021
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 Commenti
Walter Roberson
Walter Roberson il 14 Ago 2018
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 il 14 Ago 2018
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.

Risposte (0)

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by