quantize and increase variable in fminimax

조회 수: 2 (최근 30일)
koorosh dastan
koorosh dastan 2023년 11월 8일
댓글: koorosh dastan 2023년 11월 27일
my first question how can i increase vaariable in fminimax in below code when i add another variable only the one i put in function get value from x0 and another one remain empty
clear all
q=20;
random_numbersw = rand(1,20); % Random number from 0 to 1
random_numberst = -90 + (90 + 90) * rand(1, 20); % Random number from -90 to 90
x0 = [ random_numberst,random_numbersw ] ; %Initiat delta
ub = zeros(1, 40); % Initialize a matrix of zeros with 40 elements
ub(1:20) = 1; % Set values from 1 to 21 to 0
ub(21:40) = 90; % Set values from 22 to 40 to 90
lb = zeros(1, 40); % Initialize a matrix of zeros with 40 elements
lb(1:20) = 0; % Set values from 1 to 21 to 0
lb(21:40) = -90; % Set values from 22 to 40 to 90
[x,fval] = fminimax(@costy,x0,[],[],[],[],lb,ub);
function y = costy(w,deltaTeta)
f=9*10^9; %Freq
j=sqrt(-1); %Define Imaginary
l=(3*10^8)/f; %Lambda
k=(2*pi)/l; %Constant
d=0.5*l; %Distant of each element
q=20;
teta1=((-4):0.1:(-2));
g = zeros(q,length(teta1));
for h=1:q
for aa = 1:length(teta1)
g(h,aa) = g(h,aa)+(w(h) * ( exp(j*(h-1) * (k*d*sind(teta1(aa)+deltaTeta(h)))))); %w W
end
end
y = abs(sum(g,1));
end
here first is w and second one is detaTeta
  댓글 수: 4
Lea
Lea 2023년 11월 17일
You have set up your cost function as a function of two variables, but it should have one, see https://www.mathworks.com/help/optim/ug/passing-extra-parameters.html. Also, is your cost function guaranteed to be a real number? Note that you can't optimize a complex objective.
koorosh dastan
koorosh dastan 2023년 11월 27일
thx i change it to this
g(h,aa) = g(h,aa)+(deltaTeta(h) * ( exp(j*(h-1) * (k*d*sind(teta1(aa)+deltaTeta(h+q)))))); %w W
end
so i have only one input
but how can i quantize my deltateta that means
i like to change deltateta(1:20) whith step of 0.1 but from deltaTeta(21:40) it change with step of 5

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by