Equation solution is not found for all array element

1 次查看(过去 30 天)
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.

采纳的回答

John D'Errico
John D'Errico 2023-3-31
编辑:John D'Errico 2023-3-31
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 个评论
Walter Roberson
Walter Roberson 2023-4-1
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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by