jch029 2019-09-10 10:13 采纳率: 100%
浏览 1387

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条回答

  • 关注
    评论

报告相同问题?

悬赏问题

  • ¥15 MATLAB怎么通过柱坐标变换画开口是圆形的旋转抛物面?
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿