Omega=10:10000:4e6;
for i=1:1:400
finalresp(i)=abs((TransOpt(x,Omega(i))-Z(i))^2);
end
You should be pre-allocating finalresp.
It would be better not to assume that Omega is exactly length 400, and to loop to length(Omega) instead of to 400.
Well, that is obviously going to be a vector result, of length 400. ga() cannot process a vector result. gamultiobj() can process a vector result -- but do you really want to optimize for the pareto fronts of finalresp, or do you instead want to optimize some property of finalresp() as a whole, such as sum(finalresp) ?
If you are going for minimum residue, then I recommend that you switch to
finalresp = zeros(size(Omega));
for i = 1 : length(Omega)
finalresp(i)=(TransOpt(x,Omega(i))-Z(i))^2;
end
y = sum(finalresp);
because abs() is not differentiable .
Exception: if Z can be complex valued, then
finalresp = zeros(size(Omega));
for i = 1 : length(Omega)
temp = (TransOpt(x,Omega(i))-Z(i))^2;
finalresp(i) = temp .* conj(temp);
end
y = sum(finalresp);
load('Z.mat')
We do not have Z.mat to test with.
Omega=10:10000:4e6;
for i=1:1:400
finalresp(i)=abs((TransOpt(x,Omega(i))-Z(i))^2);
end
You should be pre-allocating finalresp.
It would be better not to assume that Omega is exactly length 400, and to loop to length(Omega) instead of to 400.
Well, that is obviously going to be a vector result, of length 400. ga() cannot process a vector result. gamultiobj() can process a vector result -- but do you really want to optimize for the pareto fronts of finalresp, or do you instead want to optimize some property of finalresp() as a whole, such as sum(finalresp) ?
If you are going for minimum residue, then I recommend that you switch to
finalresp = zeros(size(Omega));
for i = 1 : length(Omega)
finalresp(i)=(TransOpt(x,Omega(i))-Z(i))^2;
end
y = sum(finalresp);
because abs() is not differentiable .
Exception: if Z can be complex valued, then
finalresp = zeros(size(Omega));
for i = 1 : length(Omega)
temp = (TransOpt(x,Omega(i))-Z(i))^2;
finalresp(i) = temp .* conj(temp);
end
y = sum(finalresp);