optimization problem for exponential coefficients
1 次查看(过去 30 天)
显示 更早的评论
Hello , i have the attached code which produces certain radiation pattern shown below.
basicly in matlab view its AF,theta plot.
In in code the coeeficients of real_voltage phases are known, however i want to create a code which given AF,theta it whould return me the best optimized real_voltage phases coefficients.
Thanks.
theta=linspace(-pi/2,pi/2,1000);
f=5.6;
N=6;
lambda=300/f;
d=0.8*lambda;
theta_0=pi*((0)/180);
amplitude_norm_V=[0.05,0.3,0.75,1,0.75,0.3,0.05];
k=(2*pi)/lambda;
delta=k*d*cos(theta_0);
x=sqrt(1/(sum(amplitude_norm_V.^2)));
real_voltage=amplitude_norm_V.*x;
real_power=(real_voltage.^2);
sum(real_power);
phases=[0,0,0,0,0,0,0];
total=0;
tot=0;
for z=1:6
AF=real_voltage(z)*exp(1i*(phases(z)/180*pi))*exp(-1i*(z-1)*k*d*cos(theta)+1i*(z-1)*delta);
total=total+AF;
end
plot((theta/pi)*180,20*log10(total)), grid on
回答(1 个)
Morgan
2024-3-25
The function you're fitting to looks like:
3 个评论
Morgan
2024-3-26
编辑:Morgan
2024-3-26
% NUMBER OF FIT PARAMETERS
N = 6;
% THETA ARRAY
theta = linspace(-pi/2,+pi/2,1000);
% V DATA
V = ... % Your data for V that has length of N
% AF DATA
AF = ... % Your data for AF the same size as theta
% COEFFICIENT GUESS
beta0 = zeros(1,N);
% SOLVE NONLINEAR REGRESSION MODEL
mdl = fitnlm(theta,AF,@(b,theta) modelfun(b,theta,V),beta0)
% FUNCTION MODEL
function y = modelfun(b,theta,V)
y = 0;
for n = 1 : length(V)
y = y + V(n)*exp(1i*b(n))*exp(1i*(n-1)*(delta - k*d*cos(theta)));
end
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Nonlinear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!