Inconsistent row/column dimensions.
1 次查看(过去 30 天)
显示 更早的评论
l=633*(10)^(-9);
k0=(2*pi)/l;
nc=1.33;
na=1.43265;
nf=1.59;
nm=0.064+1i*4;
ns=1.49;
a=54:0.01:70
df=1:1:300;
nf=1.59;
k0=(2*pi/633);
Nm=nf*sind(a);
Snc=zeros(length(a),length(df));
Sna=zeros(length(a),length(df));
Sda=zeros(length(a),length(df));
p=1;
ds=((1-p)./(k0.*sqrt(Nm.^2-ns.^2)))+(p./((Nm./nf).^2+(Nm./ns).^2-1).*(k0.*sqrt(Nm.^2-ns.^2)));
dc=((1-p)./(k0.*sqrt(Nm.^2-nc.^2)))+(p./((Nm./nf).^2+(Nm./nc).^2-1).*(k0.*sqrt(Nm.^2-nc.^2)));
da=((1-p)./(k0.*sqrt(Nm.^2-na.^2)))+(p./((Nm./nf).^2+(Nm./na).^2-1).*(k0.*sqrt(Nm.^2-na.^2)));
Snc= ((nc/Nm).*((nf.^2-Nm.^2)./(nf.^2-nc.^2)).*(dc./(ds+df+dc)).*(2.*(Nm.^2./nc.^2)-1));
Sna= ((na./Nm).*((nf.^2-Nm.^2)./(nf.^2-na.^2)).*(da./(ds+df+da)).*(2.*(Nm.^2./na.^2)-1));
Sda= (((nf.^2-Nm.^2)./(Nm.*(ds+df+dc))).*((na.^2-nc.^2)./(nf.^2-nc.^2)).*((((Nm./nc).^2)+((Nm./na).^2)-1)./( ((Nm./nc).^2)+((Nm./nf).^2)-1))).^p;
plot(df,Snc)
采纳的回答
KSSV
2022-2-10
l=633*(10)^(-9);
k0=(2*pi)/l;
nc=1.33;
na=1.43265;
nf=1.59;
nm=0.064+1i*4;
ns=1.49;
a=54:0.01:70 ;
df=linspace(1,300,length(a));
nf=1.59;
k0=(2*pi/633);
Nm=nf*sind(a);
p=1;
ds=((1-p)./(k0.*sqrt(Nm.^2-ns.^2)))+(p./((Nm./nf).^2+(Nm./ns).^2-1).*(k0.*sqrt(Nm.^2-ns.^2)));
dc=((1-p)./(k0.*sqrt(Nm.^2-nc.^2)))+(p./((Nm./nf).^2+(Nm./nc).^2-1).*(k0.*sqrt(Nm.^2-nc.^2)));
da=((1-p)./(k0.*sqrt(Nm.^2-na.^2)))+(p./((Nm./nf).^2+(Nm./na).^2-1).*(k0.*sqrt(Nm.^2-na.^2)));
Snc= ((nc./Nm).*((nf.^2-Nm.^2)./(nf.^2-nc.^2)).*(dc./(ds+df+dc)).*(2.*(Nm.^2./nc.^2)-1));
Sna= ((na./Nm).*((nf.^2-Nm.^2)./(nf.^2-na.^2)).*(da./(ds+df+da)).*(2.*(Nm.^2./na.^2)-1));
Sda= (((nf.^2-Nm.^2)./(Nm.*(ds+df+dc))).*((na.^2-nc.^2)./(nf.^2-nc.^2)).*((((Nm./nc).^2)+((Nm./na).^2)-1)./( ((Nm./nc).^2)+((Nm./nf).^2)-1))).^p;
plot(df,Snc)
8 个评论
KSSV
2022-2-10
Jeez you want to use initilization?
If you are using a loop and filling values into it, you have to initalize the array using zeros.
If you are not using loop and getting the LHS by vectorization, no loop is needed.
更多回答(1 个)
Gonzalo Martínez de Pissón
2022-2-10
It seems there is a problem in Snc solution. ds and dc are vectors of 1601 elements whereas df has 300 elements.
Snc= ((nc/Nm).*((nf.^2-Nm.^2)./(nf.^2-nc.^2)).*(dc./(ds+df+dc)).*(2.*(Nm.^2./nc.^2)-1));
The same in Sna line:
Sna= ((na./Nm).*((nf.^2-Nm.^2)./(nf.^2-na.^2)).*(da./(ds+df+da)).*(2.*(Nm.^2./na.^2)-1));
I don't know the aim of df but try initializing the same length as ds.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!