creating a variable address
조회 수: 3 (최근 30일)
이전 댓글 표시
I linked Matlab software with a engineering software. MATLAB software must generate a new address every time it can be used in engineering software. The general format of the addresses in the engineering software is as follows:
A.Application.Tree.FindNode('Data\Blocks\variable component\Input\MODEL_TYPE').value
that 'variable component' change every time and When this changes; The address also changes with it.
How can I creat a variable address?
is below code correct?
for i=3:size(strtbl,2)
val_type(i)=sprintf('''A.Application.Tree.FindNode(''\Data\Blocks\%s\Input\MODEL_TYPE'')''',strtbl(3,i));
end
matlab response:
Function is not defined for 'cell' inputs.
Error in Program (line 42)
val_type(i)=sprintf('''A.Application.Tree.FindNode(''\Data\Blocks\%s\Input\MODEL_TYPE'')''',strtbl(3,i));
댓글 수: 0
채택된 답변
Giuseppe Inghilterra
2020년 2월 8일
Hi,
i recommend you to use "fullfile" matlab function. This function allows you to build addresses from parts.
Thus, in your case:
variablecomponent = 'text';
fullfile('Data','Blocks',variablecomponent,'Input','MODEL_TYPE');
Thus, you vary in your for loop variablecomponent and you obtain a variable address.
Note that if variablecomponent is a cell array, where each cell contains a character array, remember to use {} brackets in your for loop. Otherwise the output of fullfile function is not a character array, but a cell array and maybe your function 'A.Application.Tree.FindNode' does not accept a cell array as input argument.
Hope this helps.
댓글 수: 1
추가 답변 (0개)
참고 항목
카테고리
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!