필터 지우기
필터 지우기

creating a variable address

조회 수: 7 (최근 30일)
Amir amini
Amir amini 2020년 2월 8일
댓글: Stephen23 2020년 2월 8일
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));

채택된 답변

Giuseppe Inghilterra
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by