matrix multiplication and root finding

2 Ansichten (letzte 30 Tage)
shiv gaur
shiv gaur am 25 Sep. 2021
Kommentiert: shiv gaur am 14 Dez. 2024
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

Akzeptierte Antwort

Vidhi Agarwal
Vidhi Agarwal am 4 Dez. 2024
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 Kommentare
shiv gaur
shiv gaur am 14 Dez. 2024
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 am 14 Dez. 2024
plot h2(x axis) vs x(real or x imaginary)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by