How to convert the attached equations in Matlab?

1 次查看(过去 30 天)
I have two equations which I have attached in the attachment here. I want to convert them in Matlab code. But how? I tried but in vain. I don't know why it cannot be coded? The required desired vector u is given belwo:
u=[1 2 0.1 0.1 3 4 30 40 50 60];% u=[a1 a2 r1 r2 f1 f2 theta1 theta2 phi1 phi2];
fmax=10;
m=1:5;
n=m;
As you can see the values of ap in given equations have 1st two values inside u namely 1 and 2. Likewise, the values of rp in given equations have 3rd and 4th values inside u. Similarly, the fp in given equations have values 3 and 4 inside u. Likewise, the values of thetap are 30 and 40 inside u and the values of phip are 50 and 60 inside u.
I want to find the values of xo and yo in MATLAB?

采纳的回答

Torsten
Torsten 2024-3-2
编辑:Torsten 2024-3-2
I'm not sure if you mean m.^2.*f.^2./16.*r or m.^2.*f.^2./(16.*r) in your equations.
I assumed that your equations.png is correct.
u=[1 2 0.1 0.1 3 4 30 40 50 60];
a = u(1:2);
r = u(3:4);
f = u(5:6);
theta = u(7:8);
phi = u(9:10);
fmax=10;
m=(1:5).';
xo = sum(a.*exp(-1i*((pi/fmax).*(-m.*f/2).*sind(theta).*cosd(phi)+m.^2.*f.^2./16.*r).*(1-sind(theta).^2.*cosd(phi).^2)),2)
xo =
2.9880 + 0.2678i 2.9975 + 0.0768i 2.9297 - 0.5680i 2.4816 - 1.5650i 1.3000 - 2.4949i
yo = sum(a.*exp(-1i*((pi/fmax).*(-m.*f/2).*sind(theta).*sind(phi)+m.^2.*f.^2./16.*r).*(1-sind(theta).^2.*sind(phi).^2)),2)
yo =
2.9647 + 0.4489i 2.9507 + 0.5263i 2.9889 + 0.2358i 2.9693 - 0.4278i 2.6463 - 1.4077i
  7 个评论
Torsten
Torsten 2024-3-3
编辑:Torsten 2024-3-3
But in this the final err is a row vector instead of a single zero value. I don't know why?
m and n are 5x1 vectors. Dividing a scalar by a 5x1 vector gives a 1x5 vector:
x = 0;
y = (1:5).';
x/y
ans = 1×5
0 0 0 0 0

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Operators and Elementary Operations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by