Way to pass to a function a random variable based on array
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a list of variables in my workspace as a string array. I want to call a function to test every combo
Unfortunately when i run as it currently is it passes the string of the varialbe name and not the variable in my workspace. I have tried using the eval command however I can't have the eval command work in a parfor loop. Unfortunately without parfor it is very slow to test.
parfor i = 1:10
for j = i:10
testprocedure(VarArray(i,1),VarArray(j,1))
end
end
댓글 수: 0
채택된 답변
Walter Roberson
2012년 3월 22일
I would suggest using a structure array in your case.
testprocedure( VarStruct.(VarArray{i}), VarStruct.(VarArray{j}) )
댓글 수: 1
Oleg Komarov
2012년 3월 22일
I am seriously thinking to resume my post on how people should scale their projects, because inevitably they end up with eval.
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!