is it possible to creat a variables with dynamices names in parfor loop
i try this code
for i = 1:N
eval(['A' num2str(i) '= 5'])
end
but i obtain "transparency violation" error .

 채택된 답변

Walter Roberson
Walter Roberson 2016년 4월 13일

2 개 추천

No. All accezses must be obvious from the text of the code.
You can put the code into a function, as then MATLAB would know that the reference was local instead of possibly being to someone created before the loop.
Creating names using eval is not recommended and there are almost always better ways such as dynamic field names

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2016년 4월 13일

댓글:

2019년 10월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by