Filter löschen
Filter löschen

Unable to perform assignment because the size of the left side is 1-by-200 and the size of the right side is 200-by-200.

2 Ansichten (letzte 30 Tage)
I need help fixing the error message above. The error is on this line of code:
Error in main_single (line 79)
chi_evan_p(a,:)=sevan_p1( w(a),beta_evan,d);
%Main code
d=100E-9; %Distance between the hot and cold stacks
q=1.602E-19;
epsilon=8.8541878128e-12;
hbar=1.054571596E-34;
hbar_eV=hbar/q; %eV
kb=1.3806503E-23;
kb_eV=kb/q;
h=2*pi*hbar;
h_eV=h/q; % eVs
T1=310; %Hot stack temperature, in K
T2=300; %Cold stack temperature, in K
c=2.9979E8; %speed of light
N=200; %no of freq point
%lambda=load("lam_data.mat");
%lambda=lambda.lam*1e-9;
%lambda=transpose(lambda);
%w1=w(1);
%w2=w(end);
w1=3.19263e13;
w2=1.88365e15;
dw=(w2-w1)/N;
w=linspace(w1,w2,N);
f=w./(2*pi);
lambda=c./f;
w_ev=w/1.5193E15;
qevan_p=zeros(1,length(w)); %vector initialization
qevan_s=zeros(1,length(w));
qprop_p=zeros(1,length(w));
qprop_s=zeros(1,length(w));
chi_evan_p=zeros(1,length(w)); %vector initialization
chi_evan_s=zeros(1,length(w));
chi_prop_p=zeros(1,length(w));
chi_prop_s=zeros(1,length(w));
hevan_p=zeros(1,length(w)); %vector initialization
hevan_s=zeros(1,length(w));
hprop_p=zeros(1,length(w));
hprop_s=zeros(1,length(w));
for a=1:length(w)
betaevanmax=1000*w(a)/c; %upper limit of the parallel wavevector for evanescent wave integration
betaevanmin=w(a)/c; %lower limit
beta_evan=(linspace(betaevanmin,betaevanmax,N));
beta_prop=(linspace(0,betaevanmin,N));
ks=integral(@(beta)sevan_p(w(a),beta, d),betaevanmin,betaevanmax,'ArrayValued', true,'Reltol',1E-6,'AbsTol',1E-10); %default abstol = 1E-10 reltol 1E-6
ks1=ks(end);
nn=integral(@(beta)sevan_p(w(a),beta, d),betaevanmin,betaevanmax,'ArrayValued', true,'Reltol',1E-6,'AbsTol',1E-10); %default abstol = 1E-10 reltol 1E-6
kp=integral(@(beta)sevan_s(w(a),beta, d),betaevanmin,betaevanmax,'ArrayValued', true,'Reltol',1E-6,'AbsTol',1E-10); %default abstol = 1E-10 reltol 1E-6
kp1=kp(end);
qevan_p(a)=(Theta(w(a), T1)-Theta(w(a), T2))*1/pi^2*ks1;
qevan_s(a)=(Theta(w(a), T1)-Theta(w(a), T2))*1/pi^2*kp1;
pp=integral(@(beta)(sprop_p(w(a),beta,d)),0,w(a)/c,'arrayvalued', true);
pp1=pp(end);
ps=integral(@(beta)(sprop_s(w(a),beta,d)),0,w(a)/c,'arrayvalued', true);
ps1=ps(end);
qprop_p(a)=(Theta(w(a), T1)-Theta(w(a), T2))*1/pi^2*pp1;
qprop_s(a)=(Theta(w(a), T1)-Theta(w(a), T2))*1/pi^2*ps1;
chi_evan_p(a,:)=sevan_p1( w(a),beta_evan,d);
chi_evan_s(a,:)=sevan_s1( w(a), beta_evan, d);
chi_prop_s(a,:)=sprop_s1( w(a), d,beta_prop);
chi_prop_p(a,:)=sprop_p1( w(a), beta_prop, d);
chi_evan=chi_evan_p(a,:)+chi_evan_s(a,:);
chi_prop=chi_prop_s(a,:)+ chi_prop_p(a,:);
a/length(w);% progress indicator
end
qtot=qevan_p+qevan_s+qprop_p+qprop_s; %total intensity spectum
  3 Kommentare
Ambali Odebowale
Ambali Odebowale am 20 Aug. 2023
sevan_p, sevan_p1, sprop_p, sprop_p1,sprop_s and sprop_s1 are functions with each having their respective codes and some other functions like theta which are not shown in the main code I posted.
The error I am getting is in the matrix dimension. Any help would be appreciated.
Thanks
Torsten
Torsten am 20 Aug. 2023
And what exactly don't you understand about the error message ?
chi_evan_p(a,:)
is an object of size 1x200, the object returned from the call
sevan_p1( w(a),beta_evan,d)
has size 200x200. So you try to store an object of size 200x200 in an object of size 1x200. Dimension overflow.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Ambali Odebowale
Ambali Odebowale am 20 Aug. 2023
Verschoben: Cris LaPierre am 21 Aug. 2023
I have identified the cause of the error. Thanks for your prompt response

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by