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.
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Torsten
2023-8-20
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.
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!