quantize and increase variable in fminimax
2 ビュー (過去 30 日間)
古いコメントを表示
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
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.
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!