How to Loop variables

15 vues (au cours des 30 derniers jours)
Poohish
Poohish le 19 Nov 2019
Commenté : Walter Roberson le 19 Nov 2019
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 commentaires
dpb
dpb le 19 Nov 2019
Use vector functions... [x(1)+x(2)+...+x(1155)] is just
sumx=sum(x);
Walter Roberson
Walter Roberson le 19 Nov 2019
x = optivar('x',1,1155,'LowerBound',0,'UpperBound',1234); %upper bound same as lower bound is unlikely
sumx = sum(x);

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by