Equation solution is not found for all array element
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mustafa
am 31 Mär. 2023
Kommentiert: Mustafa
am 3 Apr. 2023
Hi I have an equation that includes just one variable. With vpasolve command, it is just solved until 105th array value. But array length is 298x1. what is the wrong? and is there any suggestion? (my opinion is, when i equal to 106 and higher, program can't find real solution, but it should be)
clear all, clc, format shortG, close all
name="XXX";
S=load(name+".m");
F=S(:,1);
Vd=S(:,2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
syms t_bulk Te n hw me t_p eps_inf eps_s w
% consts
e=1.602E-19;
h=6.626E-34;
h_p=1.05E-34;
eps_0=8.854E-12;
kb=1.38e-23;
T_lattice=300;
m0=9.1E-31;
thickness=5E-5;
% Parameters
n=(2.59E14)/thickness;
hw=0.034*e;
me=0.057*m0;
t_p=160E-15;
eps_inf=11.46*eps_0;
eps_s=13.94*eps_0;
w=(hw/h_p);
Nc=(2*((2*pi*me*kb*T_lattice)/(h^2))^1.5)*1E-6;
K0=(hw/(2*kb*Te));
t0=1/(((e^2)*(w)/(2*pi*h_p))*sqrt(me/(2*hw))*((1/(eps_inf))-(1/(eps_s))));
t_bulk=(t0+t_p*((n*kb*Te)/(2*Nc*hw))*(1-exp(-hw/(kb*Te))));
n0=(1/(exp(hw/(kb*T_lattice))-1));
Pexp=(e.*F*1000.*Vd);
Ptheory1=((sqrt(2/pi)*(hw/t_bulk)*((n0+1)*exp(-hw/(kb*Te))-n0)*(sqrt(hw/(2*kb*Te)))*exp(hw/(2*kb*Te))*besseli(0,K0)));
Ptheory1=simplify(Ptheory1);
for i=1:length(Pexp)
T1(i,1)=double(vpasolve(Ptheory1==Pexp(i,1),Te, 1));
end
And error is below: Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 0-by-1.
0 Kommentare
Akzeptierte Antwort
John D'Errico
am 31 Mär. 2023
Bearbeitet: John D'Errico
am 31 Mär. 2023
For SOME of these sub-problems, no solution was found.
I would suggest that when the result from vpasolve is empty, you could assign a NaN for those cases.
for i=1:length(Pexp)
result = double(vpasolve(Ptheory1==Pexp(i,1),Te, 1));
if isempty(result)
T1(i,1) = NaN;
else
T1(i,1) = result;
end
end
10 Kommentare
Walter Roberson
am 1 Apr. 2023
Your Ptheory1 does not depend upon F or Vd. Instead, the product of F and Vd combine with other constants to become Pexp, the value that Ptheory1 must equal.
If you fplot(Ptheory1) in the area near 700, such as 650 to 750, then you will see that it peaks slightly less than your Pexp values. The peak is at approximately Te = 714.80196643093804698707623194146 with a value of approximately 1.2109926630804e-09
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!