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!