Inconsistent row/column dimensions.

5 ビュー (過去 30 日間)
shiv gaur
shiv gaur 2022 年 2 月 10 日
コメント済み: 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=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)
  1 件のコメント
shiv gaur
shiv gaur 2022 年 2 月 10 日
not able to plot

サインインしてコメントする。

採用された回答

KSSV
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)
Warning: Imaginary parts of complex X and/or Y arguments ignored.
  8 件のコメント
shiv gaur
shiv gaur 2022 年 2 月 10 日
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 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
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.

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by