multiply by two matrix

Mj = [cos (kj hj) i*sin(kj hj) /kj ; i*kj*sin(kj hj) cos (kj hj) ];
kj=sqrt(nj^2*k02-x^2);
Take
n1=1.521;n2=2.66;k0=1;h1=1.5e-6;h2=1e-6
multiply M1*M2

4 个评论

And the question is. . . . 🤔
This sounds like a homework assignment. If it is, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the MATLAB Onramp tutorial (https://www.mathworks.com/support/learn-with-matlab-tutorials.html) to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem, I recommend asking your professor and/or teaching assistant for help.
%this is program
function kp1
close all;
clear all;
function y=F(x)
for t2=1
k0=1;
n1=1.521;
%n2=2.66;
n2=4.1-0.211*1i;
ns=1.512;
%nc=0.15-1i*3.2;
nc=1;
k1=sqrt(n1.^2*k0.^2-x.^2);
k2=sqrt(n2.^2*k0.^2-x.^2);
t1=1.5;
m11= cos(t1*k1)*cos(t2*k2)-(k2/k1)*sin(t1*k1)*sin(t2*k2);
m12=(1/k2)*(cos(t1*k1)*sin(t2*k2)*1i) +(1/k1)*(cos(t2*k2)*sin(t1*k1)*1i);
m21= (k1)*cos(t2*k2)*sin(t1*k1)*1i +(k2)*cos(t1*k1)*sin(t2*k2)*1i;
m22=cos(t1*k1)*cos(t2*k2)-(k1/k2)*sin(t1*k1)*sin(t2*k2);
A=[m11 m12 ; m21 m22];
disp(eig(A))
gs=x.^2-ns.^2*k0.^2;
gc= x.^2-nc.^2*k0.^2;
y= 1i*(gs*m11+gc*m22)-m21+gc*gs*m12 ;
%y=x^2+x+1;
end
end
p0=1;
p1=1.5;
p2=2;
tol = 10^-5;
n = 50;
h1 = p1 - p0;
h2 = p2 - p1;
del1 = (F(p1)-F(p0))./h1;
del2 = (F(p2)-F(p1))./h2;
d = (del2-del1)./(h2+h1);
I = 3;
%Step 2
while I <= n
%Step 3
b = del2+h2.*d;
D = sqrt(b.^2-4.*F(p2).*d); % could be complex
%Step 4
if abs(b - D) < abs(b + D)
E = b + D;
else
E = b - D;
end
%Step 5
h = -2.*F(p2)./E;
p = p2 + h;
if I == 3
table{1} = 'Muller''s Method Iterations';
table{2}=' I P f(P) ';
table{3}='-----------------------------------------------------';
end
str = sprintf('%3u: % 6.6f + %6.6fi % 6.6f + %6.6fi',I,real(p),imag(p),real(F(p)),imag(F(p)));
table{I + 1} = str; %#ok<*AGROW>
%Step 6
if abs(h) < tol
val = p;
table = char(table);
break
end
p0 = p1;
p1 = p2;
p2 = p;
h1 = p1 - p0;
h2 = p2 - p1;
del1 = (F(p1)-F(p0))./h1;
del2 = (F(p2)-F(p1))./h2;
d = (del2-del1)./(h2+h1);
I = I + 1;
end
disp(p)
end
Please format your code properly. Use the icons on top of the field for editing in the forum.
You still did not ask a question.

请先登录,再进行评论。

回答(1 个)

syms x
n = [1.521, 2.66];
k0 = 1;
h = [1.5e-6, 1e-6];
k = @(j) sqrt(n(j).^2*k0.^2-x.^2);
M = @(j) [
cos(k(j) .* h(j)), i*sin(k(j) .* h(j))/k(j)
i .* k(j) .* sin(k(j).*h(j)), cos(k(j) .* h(j))
]
M = function_handle with value:
@(j)[cos(k(j).*h(j)),i*sin(k(j).*h(j))/k(j);i.*k(j).*sin(k(j).*h(j)),cos(k(j).*h(j))]
M12 = M(1) * M(2)
M12 = 

类别

帮助中心File Exchange 中查找有关 Mathematics 的更多信息

产品

版本

R2021a

标签

Community Treasure Hunt

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

Start Hunting!

Translated by