GEtting err0r
이전 댓글 표시
Getting error In Code
Unable to perform assignment because dot indexing is not supported for variables of this type.
x=optimvar('x',3,'LowerBound',[0, 0, -inf],'UpperBound',[inf, inf, inf]);
Obj=(x(1)-(2 *x(2))+3*x(3));
A =x(1)+x(2)+x(3)<=7;
B =-x(1)+x(2)-x(3)<=2;
C =3*x(1)-x(2)-2*x(3)==-5;
Problem=optimproblem('Objective',Obj,'ObjectiveSense','maximize');
Problem.Constraints.con_1 = A;
Problem.Constraints.con_2 = B;
Problem.Constraints.con_3 = C;
x0.x=[0 0 0];
[sol,xfval,exitflag,output] = solve(Problem,x0)
Unable to perform assignment because dot indexing is not supported for variables of this type.
pls Guide me
댓글 수: 3
Vivek
2022년 9월 15일
Code works for me here.
x=optimvar('x',3,'LowerBound',[0, 0, -inf],'UpperBound',[inf, inf, inf]);
Obj=(x(1)-(2 *x(2))+3*x(3));
A =x(1)+x(2)+x(3)<=7;
B =-x(1)+x(2)-x(3)<=2;
C =3*x(1)-x(2)-2*x(3)==-5;
Problem=optimproblem('Objective',Obj,'ObjectiveSense','maximize');
Problem.Constraints.con_1 = A;
Problem.Constraints.con_2 = B;
Problem.Constraints.con_3 = C;
x0.x=[0 0 0];
[sol,xfval,exitflag,output] = solve(Problem,x0)
sol.x
답변 (1개)
Walter Roberson
2022년 9월 15일
편집: Walter Roberson
2022년 9월 15일
1 개 추천
you have an existing numeric variable named x0 and so you not permitted to assign to x0.x because numeric variables cannot use dot indexing.
This is the kind of problem that using functions instead of scripts is designed to solve.
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!