How to Loop variables

조회 수: 1 (최근 30일)
Poohish
Poohish 2019년 11월 19일
댓글: Walter Roberson 2019년 11월 19일
Look the example of this:
The objective of the example is x(1) + x(2). It is easy to type manually.
But I have 1155 variable [meaning x(1)+x(2)+...+x(1155)] to optimise and it will take ages to type manually. Thus I must use loop.
My main part is to solve optivar('x',1,1155,'LowerBound',0,'UpperBound',0) - 1155 variables.
How to use the loop in here?
  댓글 수: 2
dpb
dpb 2019년 11월 19일
Use vector functions... [x(1)+x(2)+...+x(1155)] is just
sumx=sum(x);
Walter Roberson
Walter Roberson 2019년 11월 19일
x = optivar('x',1,1155,'LowerBound',0,'UpperBound',1234); %upper bound same as lower bound is unlikely
sumx = sum(x);

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by