matrix multiplication and root finding

조회 수: 2 (최근 30일)
shiv gaur
shiv gaur 2021년 9월 25일
댓글: shiv gaur 2024년 12월 14일
Mj=[cos (kj hj) i*sin(kj hj) /kj ; i*kj*sin(kj hj) cos (kj hj) ];
kj=sqrt(nj2*k02-x2);
Take n1=1.521;n2=2.66;k0=1;h1=1.5e-6;h2=1e-6
We take M=M1*M2;
Where M=( m11 m12;m21 m22) as usual in
Matrix;
How to multiply this matrix for M find the multiplication of matrix and find the value of
x;
and solve the eq
ns=1.512;
nc=1.2-i7;
gs=x2-ns2k02;
gc= x2-ns2k02;
f(x)=igsm11+gcm22)-m21+gsgcm12;
and solve the eq and value of x

채택된 답변

Vidhi Agarwal
Vidhi Agarwal 2024년 12월 4일
To solve the issue follow the given below steps:
  • Define the matrices.
  • Compute the matrix multiplication.
  • Formulate the function.
  • Solve the equation.
Modified code for the same is given below:
% Given values
n1 = 1.521;
n2 = 2.66;
k0 = 1;
h1 = 1.5e-6;
h2 = 1e-6;
ns = 1.512;
nc = 1.2 - 1i*7;
% Define symbolic variable for x
syms x
% Calculate k1 and k2
k1 = sqrt(n1^2 * k0^2 - x^2);
k2 = sqrt(n2^2 * k0^2 - x^2);
% Define M1 and M2 matrices
M1 = [cos(k1 * h1), 1i * sin(k1 * h1) / k1;
1i * k1 * sin(k1 * h1), cos(k1 * h1)];
M2 = [cos(k2 * h2), 1i * sin(k2 * h2) / k2;
1i * k2 * sin(k2 * h2), cos(k2 * h2)];
% Multiply matrices to get M
M = M1 * M2;
% Extract elements from M
m11 = M(1,1);
m12 = M(1,2);
m21 = M(2,1);
m22 = M(2,2);
% Define gs and gc
gs = x^2 - ns^2 * k0^2;
gc = x^2 - nc^2 * k0^2;
% Define the function f(x)
f = 1i * (gs * m11 + gc * m22) - m21 + gs * gc * m12;
% Use vpasolve for numerical solution
x_solution = vpasolve(f == 0, x);
% Display the solutions
disp('Numerical solutions for x:')
disp(x_solution)
For better understanding of basic matrix operation in MATLAB refer to the documentation https://www.mathworks.com/help/matlab/math/basic-matrix-operations.html.
Hope this helps!
  댓글 수: 2
shiv gaur
shiv gaur 2024년 12월 14일
thanks for answer.what will be change in program if we varying h2 from 1e-3 to 1e-6 pl provide the solution
shiv gaur
shiv gaur 2024년 12월 14일
plot h2(x axis) vs x(real or x imaginary)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by