Preallocating a variable that changes size every for loop iterations.

조회 수: 2 (최근 30일)
Heg Vel
Heg Vel 2020년 9월 25일
댓글: Sindar 2020년 9월 25일
I am using a variable indices that changes size like three times in an iteration .Preallocating it does not change anything.
  댓글 수: 1
Heg Vel
Heg Vel 2020년 9월 25일
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.

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

답변 (1개)

Sindar
Sindar 2020년 9월 25일
It's just a code suggestion, you can safely ignore it.
  댓글 수: 3
Heg Vel
Heg Vel 2020년 9월 25일
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 2020년 9월 25일
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)

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

카테고리

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