quantize and increase variable in fminimax

2 views (last 30 days)
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 Comments
Lea
Lea on 17 Nov 2023
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 on 27 Nov 2023
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

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!