How to convert the attached equations in Matlab?

조회 수: 5 (최근 30일)
Sadiq Akbar
Sadiq Akbar 2024년 3월 2일
댓글: Sadiq Akbar 2024년 3월 3일
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
Sadiq Akbar
Sadiq Akbar 2024년 3월 3일
Thanks a lot for your guiadance.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Least Squares에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by