Are the variables(fminimax) independent of each other?
in this code i have 68 variable half of them between [0,1] and next half [-90,90]
the first half change reasonable but others dont change (almost 0.3) and dont go to minus area
are they related to each other?
% close all
clear all
elementNumb=34;
%%
%%with W
% random_numbersw = rand(1,elementNumb); % Random number from 0 to 1
random_numbersw = ones(1,elementNumb);
ubb=90;
lbb=-90;
% random_numberst = lbb + (ubb + ubb) * rand(1, elementNumb); % Random number from -90 to 90
random_numberst =12* (ones(1 , elementNumb));
x0 = [ random_numbersw,random_numberst ] ;
ub = zeros(1, elementNumb*2); % Initialize a matrix of zeros with 40 elements
ub(1:elementNumb) = 1; % Set values from 1 to 21 to 0
ub(elementNumb+1:elementNumb*2) = ubb; % Set values from 22 to 40 to 90
lb = zeros(1, elementNumb*2); % Initialize a matrix of zeros with 40 elements
lb(1:elementNumb) = 0.000001; % Set values from 1 to 21 to 0
lb(elementNumb+1:elementNumb*2) = lbb; % Set values from 22 to 40 to 90
%%
%%Fminimax
% options = optimoptions(@fminimax,’disp’,’iter’,’Diagnostics’,…
% ‘on’, ‘FiniteDifferenceStepSize’,1e-3,…
% ‘FunctionTolerance’,1e-9,’MaxFunctionEvaluations’,20000,’FunValCheck’,’on’,’ConstraintTolerance’,0);
% options = optimoptions(@fminimax,’disp’,’iter’,’Diagnostics’,…
% ‘on’,…
% ‘FunctionTolerance’,1e-9,’MaxFunctionEvaluations’,2000,’FunValCheck’,’on’);
% % options=optimset(‘disp’,’iter’,’LargeScale’,’off’,’Diagnostics’,…
% ‘on’,’TolFun’,.00000000000001,’MaxIter’,10000,’MaxFunEvals’,1000000);
[x,fval,maxfval,exitflag,output,lambda] = fminimax(@costy,x0,[],[],[],[],lb,ub,[]);
%%function
function y = costy(x)
freq = 9*10^9; %Freq
j = sqrt(-1); %Define Imaginary
l =(3*10^8)/freq; %Lambda
k = (2*pi)/l; %Constant
d = 0.5*l; %Distant of each element
elementNumb = 34;
step = 0.1;
teta1 = ((-80) :step: (-50));
tetat = teta1;
g = zeros(elementNumb,length(tetat));
for h = 1:elementNumb
for aa = 1:length(teta1)
g(h,aa) = g(h,aa)+(x(h) * ( exp(-j*(h-1) * (k*d*sind(teta1(aa)+x(h+elementNumb)))))); %w W
end
end
y = abs(sum(g,1));
end
and can they change with certain step for example first half 0.01 and second 5in this code i have 68 variable half of them between [0,1] and next half [-90,90]
the first half change reasonable but others dont change (almost 0.3) and dont go to minus area
are they related to each other?
% close all
clear all
elementNumb=34;
%%
%%with W
% random_numbersw = rand(1,elementNumb); % Random number from 0 to 1
random_numbersw = ones(1,elementNumb);
ubb=90;
lbb=-90;
% random_numberst = lbb + (ubb + ubb) * rand(1, elementNumb); % Random number from -90 to 90
random_numberst =12* (ones(1 , elementNumb));
x0 = [ random_numbersw,random_numberst ] ;
ub = zeros(1, elementNumb*2); % Initialize a matrix of zeros with 40 elements
ub(1:elementNumb) = 1; % Set values from 1 to 21 to 0
ub(elementNumb+1:elementNumb*2) = ubb; % Set values from 22 to 40 to 90
lb = zeros(1, elementNumb*2); % Initialize a matrix of zeros with 40 elements
lb(1:elementNumb) = 0.000001; % Set values from 1 to 21 to 0
lb(elementNumb+1:elementNumb*2) = lbb; % Set values from 22 to 40 to 90
%%
%%Fminimax
% options = optimoptions(@fminimax,’disp’,’iter’,’Diagnostics’,…
% ‘on’, ‘FiniteDifferenceStepSize’,1e-3,…
% ‘FunctionTolerance’,1e-9,’MaxFunctionEvaluations’,20000,’FunValCheck’,’on’,’ConstraintTolerance’,0);
% options = optimoptions(@fminimax,’disp’,’iter’,’Diagnostics’,…
% ‘on’,…
% ‘FunctionTolerance’,1e-9,’MaxFunctionEvaluations’,2000,’FunValCheck’,’on’);
% % options=optimset(‘disp’,’iter’,’LargeScale’,’off’,’Diagnostics’,…
% ‘on’,’TolFun’,.00000000000001,’MaxIter’,10000,’MaxFunEvals’,1000000);
[x,fval,maxfval,exitflag,output,lambda] = fminimax(@costy,x0,[],[],[],[],lb,ub,[]);
%%function
function y = costy(x)
freq = 9*10^9; %Freq
j = sqrt(-1); %Define Imaginary
l =(3*10^8)/freq; %Lambda
k = (2*pi)/l; %Constant
d = 0.5*l; %Distant of each element
elementNumb = 34;
step = 0.1;
teta1 = ((-80) :step: (-50));
tetat = teta1;
g = zeros(elementNumb,length(tetat));
for h = 1:elementNumb
for aa = 1:length(teta1)
g(h,aa) = g(h,aa)+(x(h) * ( exp(-j*(h-1) * (k*d*sind(teta1(aa)+x(h+elementNumb)))))); %w W
end
end
y = abs(sum(g,1));
end
and can they change with certain step for example first half 0.01 and second 5 in this code i have 68 variable half of them between [0,1] and next half [-90,90]
the first half change reasonable but others dont change (almost 0.3) and dont go to minus area
are they related to each other?
% close all
clear all
elementNumb=34;
%%
%%with W
% random_numbersw = rand(1,elementNumb); % Random number from 0 to 1
random_numbersw = ones(1,elementNumb);
ubb=90;
lbb=-90;
% random_numberst = lbb + (ubb + ubb) * rand(1, elementNumb); % Random number from -90 to 90
random_numberst =12* (ones(1 , elementNumb));
x0 = [ random_numbersw,random_numberst ] ;
ub = zeros(1, elementNumb*2); % Initialize a matrix of zeros with 40 elements
ub(1:elementNumb) = 1; % Set values from 1 to 21 to 0
ub(elementNumb+1:elementNumb*2) = ubb; % Set values from 22 to 40 to 90
lb = zeros(1, elementNumb*2); % Initialize a matrix of zeros with 40 elements
lb(1:elementNumb) = 0.000001; % Set values from 1 to 21 to 0
lb(elementNumb+1:elementNumb*2) = lbb; % Set values from 22 to 40 to 90
%%
%%Fminimax
% options = optimoptions(@fminimax,’disp’,’iter’,’Diagnostics’,…
% ‘on’, ‘FiniteDifferenceStepSize’,1e-3,…
% ‘FunctionTolerance’,1e-9,’MaxFunctionEvaluations’,20000,’FunValCheck’,’on’,’ConstraintTolerance’,0);
% options = optimoptions(@fminimax,’disp’,’iter’,’Diagnostics’,…
% ‘on’,…
% ‘FunctionTolerance’,1e-9,’MaxFunctionEvaluations’,2000,’FunValCheck’,’on’);
% % options=optimset(‘disp’,’iter’,’LargeScale’,’off’,’Diagnostics’,…
% ‘on’,’TolFun’,.00000000000001,’MaxIter’,10000,’MaxFunEvals’,1000000);
[x,fval,maxfval,exitflag,output,lambda] = fminimax(@costy,x0,[],[],[],[],lb,ub,[]);
%%function
function y = costy(x)
freq = 9*10^9; %Freq
j = sqrt(-1); %Define Imaginary
l =(3*10^8)/freq; %Lambda
k = (2*pi)/l; %Constant
d = 0.5*l; %Distant of each element
elementNumb = 34;
step = 0.1;
teta1 = ((-80) :step: (-50));
tetat = teta1;
g = zeros(elementNumb,length(tetat));
for h = 1:elementNumb
for aa = 1:length(teta1)
g(h,aa) = g(h,aa)+(x(h) * ( exp(-j*(h-1) * (k*d*sind(teta1(aa)+x(h+elementNumb)))))); %w W
end
end
y = abs(sum(g,1));
end
and can they change with certain step for example first half 0.01 and second 5 optimization, variables MATLAB Answers — New Questions