Inconsistent row/column dimensions.
1 view (last 30 days)
Show older comments
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)
Accepted Answer
KSSV
on 10 Feb 2022
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 Comments
KSSV
on 10 Feb 2022
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.
More Answers (1)
Gonzalo Martínez de Pissón
on 10 Feb 2022
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 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!