I want to find the value of complex E_k and F_k

1 次查看(过去 30 天)
clear all
clc
x = -0.5:0.0294:0.5;
y = -0.5:0.0294:0.5;
syms E_k F_k
a=0.005;
z = x + 1i * y;
s1=0;
for k = 1 : 15
A = E_k * sqrt(z.^(2)-a^(2) * z.^(2*k-2)) + sqrt((conj(z).^2) - a.^2 * conj(z).^(2*k-2));
B = F_k * (z.^(2*k-1) - (conj(z).^(2*k-1)));
C = E_k * ((2*k-1) * z.^(2*k-1) - (2*k-2) * a.^2 * z.^(2*k-3));
D = F_k * ((2*k-1) * z.^(2*k-2));
end
C = rdivide(C, sqrt(z.^2 - a.^2));
E = C + D;
E = conj(E);
E = (z - conj(z)) .* E;
F = -(2.5 * sin(45) - cos(45)) * z + 1i * (sin(45) + 2.5*cos(45)) * conj(z);
lhs = A + B + E + F;
plhs = real(lhs);
qlhs = imag(lhs);
rhs_x = 0;
for k1 = x
rhs_x = rhs_x + 2.5 * k1;
end
rhs_y = 0;
for k1 = y
rhs_y = rhs_y + 1i * k1;
end
rhs = 1i * (rhs_x + rhs_y);
prhs = real(rhs);
qrhs = imag(rhs);
syms E_k F_k
eqn = [plhs == prhs, qlhs == qrhs];
[E_k, F_k] = solve(eqn, E_k, F_k);
  2 个评论
Paul
Paul 2023-1-11
As best I can tell, eqn can be written in the form A*x = b, where x = [E_k; F_k] and A is a 70 x 2 matrix. Is there good reason to think that such an overdetermined system will have a solution?
Also, the trig functions cos and others take input argument in radians. Use cosd and others for input argument in degrees.
sudhanshu rana
sudhanshu rana 2023-1-11
How can I write(E_K,F_K) in term of x? As we know that E_K and F_K are the two complex variables that is unknown.so that equation are like that only. I attached the photo of the equation. Can we please help me out to find the value of E_K,F_K.

请先登录,再进行评论。

回答(1 个)

Kartik
Kartik 2023-4-17
Hi,
To express the values of E_k and F_k in terms of x, you need to replace z with x + 1i*y in your equations and solve for E_k and F_k using the 'solve' function. Here is the modified code:
clear all
clc
x = -0.5:0.0294:0.5;
y = -0.5:0.0294:0.5;
syms E_k F_k
a=0.005;
s1=0;
for k = 1 : 15
z = x + 1i * y;
A = E_k * sqrt(z.^(2)-a^(2) * z.^(2*k-2)) + sqrt((conj(z).^2) - a.^2 * conj(z).^(2*k-2));
B = F_k * (z.^(2*k-1) - (conj(z).^(2*k-1)));
C = E_k * ((2*k-1) * z.^(2*k-1) - (2*k-2) * a.^2 * z.^(2*k-3));
D = F_k * ((2*k-1) * z.^(2*k-2));
C = rdivide(C, sqrt(z.^2 - a.^2));
E = C + D;
E = conj(E);
E = (z - conj(z)) .* E;
F = -(2.5 * sin(45) - cos(45)) * z + 1i * (sin(45) + 2.5*cos(45)) * conj(z);
lhs = A + B + E + F;
plhs = real(lhs);
qlhs = imag(lhs);
rhs_x = 0;
for k1 = x
rhs_x = rhs_x + 2.5 * k1;
end
rhs_y = 0;
for k1 = y
rhs_y = rhs_y + 1i * k1;
end
rhs = 1i * (rhs_x + rhs_y);
prhs = real(rhs);
qrhs = imag(rhs);
eqn = [plhs == prhs, qlhs == qrhs];
[solE, solF] = solve(eqn, E_k, F_k);
E_k_sol(:,k) = double(subs(solE)); % Solution of E_k for kth iteration
F_k_sol(:,k) = double(subs(solF)); % Solution of F_k for kth iteration
end
The modified code uses a loop to solve for E_k and F_k for each value of x. The solutions are stored in the arrays E_k_sol and F_k_sol, where each column corresponds to a different value of k.

类别

Help CenterFile Exchange 中查找有关 Trigonometry 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by