Equation solution is not found for all array element
2 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
John D'Errico
on 31 Mar 2023
Edited: John D'Errico
on 31 Mar 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
More Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!