jch029
jch029
采纳率25%
2019-09-10 10:13 阅读 896

matlab中 错误使用 * 内部矩阵维度必须一致。 出错 tmmcoupling (line 49) F = F*ff;

clear all
clc
%======================================================================
% Fibre simulation parameters
lamdaD = 1.55e-6; %design wavelength
lamda1 = 0.999*lamdaD;
lamda2 = 1.001*lamdaD;
step = 500;
lambda = (lamda1:(lamda2-lamda1)/step:lamda2);
%======================================================================
%For a grating of maximun reflectance R = 0.2
Rmax = 0.2; %required maximum reflectivity
rmax = sqrt(Rmax);
kacL = atanh(rmax);
c = 3e8; %Speed of light
h = 25e-9;
t = linspace(0,1,2000);
z = linspace(0,3000e-6,2000);
v = 1;%Fringe visibilty
%======================================================================
%Implementation of the transfer matrix method for solution of
%coupled-mode equations
L = 3000e-6; %length of grating in micrometers
M = 100;
dz = L/M;
dzo = - L + 10.69e-3; %Distance between gratings
kac = kacL/L; %"AC" coupling coefficient
kdc = 2*kac/v; %"DC" coupling coefficient
neff = 1+v*cos(cos(t)+2*pi*z./dz); %core index of photosensitive fibre
for r = 1:step+1
w = lambda(r);
F = [1 0; 0 1];
for s = 1:M
det = 2*pi*neff*(1/w - 1/lamdaD);
gdc = det + kdc;
p1 = sqrt(kac.^2 - gdc.^2);
p2 = gdc.^2/kac.^2;
f11 = cosh(p1*dz) - 1i*(gdc./p1).*sinh(p1*dz);
f12 = -1i*(kac./p1).*sinh(p1.*dz);
f21 = 1i*(kac./p1).*sinh(p1*dz);
f22 = cosh(p1*dz) + 1i*(gdc/p1).*sinh(p1*dz);
ff = [f11 f12; f21 f22];
F = F*ff;
end
提示我矩阵内部维度不一致,但是中断for循环后语句没有问题,请问该如何修改

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

相关推荐