Inconsistent row/column dimensions.

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)

 Respuesta aceptada

KSSV
KSSV el 10 de Feb. de 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)
Warning: Imaginary parts of complex X and/or Y arguments ignored.

8 comentarios

shiv gaur
shiv gaur el 10 de Feb. de 2022
how we use zeros in this program
KSSV
KSSV el 10 de Feb. de 2022
What zeros?
shiv gaur
shiv gaur el 10 de Feb. de 2022
use of zeros of the df
KSSV
KSSV el 10 de Feb. de 2022
Did you raise any question regarding use of zeros of df? What was your question and what you are expecting?
shiv gaur
shiv gaur el 10 de Feb. de 2022
if you have idea of using zeros so pl help because I have use zeros in initial program
KSSV
KSSV el 10 de Feb. de 2022
I know zero is represented by 0. How and why you want to use here?
shiv gaur
shiv gaur el 10 de Feb. de 2022
for exaple this type of program example program for use of zeros for initialization
function kk1
clc;clear;close all;
l=633;
c = 1;
k0=2*pi/l;
ea=1.39;
da=1:300;
theta=1:70;
y=zeros(length(theta),length(da));
np=1.5;
x=(2*pi/l)*np*sind(theta);
function y=f(theta,da)
for i=1:length(theta)
iter = 0;
for j=1:length(da)
iter
ka=k0*sqrt(ea-x.^2);
f=(1-exp(2*1i.*da(j).*ka(i)))/(1+exp(2*1i.*da(j).*ka(i)));
%pfms=2*atan(1i*a.*b);
y(i,j)=2*atan(1i*c.*f);
% disp(y);
iter = iter + 1;
end
end
end
plot(da,y )
end
KSSV
KSSV el 10 de Feb. de 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.

Iniciar sesión para comentar.

Más respuestas (1)

Gonzalo Martínez de Pissón
Gonzalo Martínez de Pissón el 10 de Feb. de 2022

0 votos

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.

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Productos

Versión

R2021b

Etiquetas

Preguntada:

el 10 de Feb. de 2022

Comentada:

el 10 de Feb. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by