taylor expansion of multivariate function

조회 수: 4 (최근 30일)
nasim mh
nasim mh 2023년 6월 2일
이동: Torsten 2023년 6월 5일
Hello everyone,
Would you please help me to find first-order taylor expansion of this non-linear multivariate function of 3*M variables. I try matlab tylor function for multi variable functions but I got the error that "not enough input arguments".
matlab code of this function is here:
w = [1 0 0 0];
M = length(w);
x = sym('x', [1 M]);
y = sym('y', [1 M]);
z = sym('z', [1 M]);
p0 = zeros(3, M);
a_f = @(theta, phi) 0;
for m = 1:M
f = @(theta,phi, x, y, z) (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, x, y, z) 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_phi = @(phi, x, y, z) int(@(theta) integrand(theta, phi, x, y, z), theta_limits(1), theta_limits(2));
Denominator = @(x, y, z) int(@(phi) Denominator_phi(phi, x, y, z), phi_limits(1), phi_limits(2));
% Calculate the maximum array factor
Numerator = @(x, y, z) abs(a_f(theta_max, phi_max)).^2;
% Calculate the directivity
D = @(x, y, z) 4*pi*Numerator(x,y,z) ./ Denominator(x,y,z);
L_D = taylor(D, ...
[x(1) x(2) x(3) x(4) y(1) y(2) y(3) y(4) z(1) z(2) z(3) z(4)],...
reshape(p0', 1, []), 'order', 1)
  댓글 수: 6
Torsten
Torsten 2023년 6월 3일
편집: Torsten 2023년 6월 3일
syms theta phi rho theta_max phi_max real
w = [1 0 0 0];
M = length(w);
x = sym('x', [1 M]);
y = sym('y', [1 M]);
z = sym('z', [1 M]);
assume(x,'real')
assume(y,'real')
assume(z,'real')
p0 = zeros(3, M);
AF(theta,phi) = sum((exp(1j*rho*(x(1:M).*sin(theta).*cos(phi) + ...
y(1:M).*sin(theta).*sin(phi) + z(1:M).*cos(theta)))).*w(1:M))
AF(theta, phi) = 
integrand = AF(theta,phi)*AF(theta,phi)'.*sin(theta)
integrand = 
% Define the integration limits
theta_limits = [0,pi];
phi_limits = [0,2*pi];
Denominator = int(int(integrand,theta,theta_limits(1),theta_limits(2)),phi,phi_limits(1),phi_limits(2))
Denominator = 
Numerator = 4*pi*AF(theta_max,phi_max)*AF(theta_max,phi_max)'
Numerator = 
D = Numerator/Denominator
D = 
1
nasim mh
nasim mh 2023년 6월 4일
이동: Torsten 2023년 6월 5일
Thanks @Torsten.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by