How to correct the error in code?
Mostra commenti meno recenti
clc;
clear all;
a1=3;b1=8;
G=[0;1.5;2;3.5;4;4.5;4.5];
L=[3.0;2.5;3.5;3.5;3.2;4.2;4.0];
H=[40;40;40;20;20;20;20];
k=2;
a1(2)=3;a1(1)=2.5;
b(2)=8 ;b(1)=7.5;
A(:,k)=ones(7,1);
A(:,k-1)=zeros(7,1);
for i=1:1:length(G)
if Egm>0
x = [x i];
elseif Egm<0
y = [y i];
else
z = [z i];
end
end
for j=x(1):1:x(length(x))
A(j,k+1)=((H(j))/(a1(k)))-1 ;
end
F1=@(A)(-H(x,:).*log(1+A(x,:))+a1(k).*(G(x,:)-A(x,:)));
x0=0;
lb1=-100;
ub1=100;
[A,fval]=fmincon(F1,x0,[],[],[],[],lb1,ub1)
While run this program an error shows
Index in position 1 exceeds array bounds.
Index must not exceed 1.
Caused by:
Failure in initial objective function evaluation. FMINCON cannot continue.
Sometimes it shows the error
Error using fmincon (line 641)
Supplied objective function must return a
scalar value.
How to correct this errors?What is the reason for this?
1 Commento
Rik
il 30 Gen 2023
I recovered the removed content from the Google cache (something which anyone can do). Editing away your question is very rude. Someone spent time reading your question, understanding your issue, figuring out the solution, and writing an answer. Now you repay that kindness by ensuring that the next person with a similar question can't benefit from this answer.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Surrogate Optimization in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!