Azzera filtri
Azzera filtri

Equation solution is not found for all array element

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

John D'Errico
John D'Errico il 31 Mar 2023
Modificato: John D'Errico il 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
  10 Commenti
Walter Roberson
Walter Roberson il 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
Mustafa
Mustafa il 3 Apr 2023
Thank you all for your valuable help.

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by