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!