Filter löschen
Filter löschen

Preallocating a variable that changes size every for loop iterations.

2 Ansichten (letzte 30 Tage)
Heg Vel
Heg Vel am 25 Sep. 2020
Kommentiert: Sindar am 25 Sep. 2020
I am using a variable indices that changes size like three times in an iteration .Preallocating it does not change anything.
  1 Kommentar
Heg Vel
Heg Vel am 25 Sep. 2020
When I run the code it says the variable needs prealloaction.I am bulding masks here that will help me like constraints in a GA code.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Sindar
Sindar am 25 Sep. 2020
It's just a code suggestion, you can safely ignore it.
  3 Kommentare
Heg Vel
Heg Vel am 25 Sep. 2020
Thank you for you answer. But still I ignore that and it gives me error in the last line of if loop:company_index_map(company)=[i] .it says :Error using containers.Map/subsasgn
Specified key type does not match the type expected for this container.
Error in pro_2_mkp_1 (line 47)
company_index_map(company)=[i];
Sindar
Sindar am 25 Sep. 2020
That's an entirely separate issue. If you want help on that, create a new question with the relevant code as a code block (not an image)

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by