필터 지우기
필터 지우기

optimization problem for exponential coefficients

조회 수: 1 (최근 30일)
fima v
fima v 2024년 3월 24일
댓글: fima v 2024년 3월 29일
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
Warning: Imaginary parts of complex X and/or Y arguments ignored.

답변 (1개)

Morgan
Morgan 2024년 3월 25일
This sounds like a non-linear regression problem if I'm understanding your question correctly.
The function you're fitting to looks like:
Use fitnlm() and how to use fitnlm() to solve for the best fit coefficients in your case.
  댓글 수: 3
Morgan
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
fima v
fima v 2024년 3월 29일
Hello, what is my expression has not jus V but also phases.How does the code will change then?
Thanks.

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

카테고리

Help CenterFile Exchange에서 Nonlinear Optimization에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by