Double integral on some variable of multivariate symbolic function

Hello everyone,
Could you please help me to find double integral on a multivariate symbolic function in which the integral must be taken on some variables and final result must be symbolic again. the aim of this issue is to obtain first order taylor expansion of final function.
the coresponding matlab code:
w = [1 0 0 0];
M = length(w);
x = sym('x', [1 M]);
y = sym('y', [1 M]);
z = sym('z', [1 M]);
a_f = @(theta, phi) 0;
for m = 1:M
f = @(theta,phi) (exp(1j*rho*(x(m).*sin(theta).*cos(phi) + ...
y(m).*sin(theta).*sin(phi) + z(m).*cos(theta)))).*w(m);
a_f = @(theta, phi) a_f(theta, phi) + f(theta, phi);
end
% Define the integrand
integrand = @(theta,phi, x, y, z) abs(a_f(theta,phi)).^2 .* sin(theta);
% Define the integration limits
theta_limits = [0,pi];
phi_limits = [0,2*pi];
% Evaluate the integral using Matlab's 'integral2' function
Denominator = integral2(@(x,y,z) integrand, theta_limits(1), theta_limits(2), ...
phi_limits(1), phi_limits(2));
% Calculate the maximum array factor
Numerator = @(x, y, z) abs(a_f(theta_max, phi_max)).^2;

2 件のコメント

Dyuman Joshi
Dyuman Joshi 2023 年 6 月 2 日
You are mixing symbolic data type with numeric data. It is best to have only a single data type through-out.
Define the independent variables theta and phi as symbolic variables and proceed further with using int twice.
Also, you have not defined "rho".
nasim mh
nasim mh 2023 年 6 月 2 日
編集済み: nasim mh 2023 年 6 月 2 日
Thanks Dyuman alot, it is worked. rho is a pre-defined constant variable.
I have another question. Is it correct the method of defining array of symbolic variables like x, y and z?
actually I have a 3*M variable function that 3 is corespond to x y and z coordinte of M points in space.

サインインしてコメントする。

回答 (0 件)

カテゴリ

質問済み:

2023 年 6 月 2 日

編集済み:

2023 年 6 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by