taylor expansion of multivariate function

2 Ansichten (letzte 30 Tage)
nasim mh
nasim mh am 2 Jun. 2023
Verschoben: Torsten am 5 Jun. 2023
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 Kommentare
Torsten
Torsten am 3 Jun. 2023
Bearbeitet: Torsten am 3 Jun. 2023
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 am 4 Jun. 2023
Verschoben: Torsten am 5 Jun. 2023
Thanks @Torsten.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Global or Multiple Starting Point Search finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by