Borrar filtros
Borrar filtros

creating a variable address

6 visualizaciones (últimos 30 días)
Amir amini
Amir amini el 8 de Feb. de 2020
Comentada: Stephen23 el 8 de Feb. de 2020
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));

Respuesta aceptada

Giuseppe Inghilterra
Giuseppe Inghilterra el 8 de Feb. de 2020
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.

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by