필터 지우기
필터 지우기

simulink components names from vector of strings

조회 수: 1 (최근 30일)
Tomas Iesmantas
Tomas Iesmantas 2011년 5월 25일
Hi, I need to generate automatical simulink model. Suppose you have some library with your components, say 'Library' and vector with names of components in library, say vector={'component1' 'component2'}. In non-automatic way you can put your component with line:
add_block('library/Component1','cas/Name1');
But does anybody know how to do it by using names in vector? e.g.
add_block('library/vector(1)','cas/Name1');
add_block('library/vector(2)','cas/Name2');
Of course, these lines does not work, I wrote it just to make clear of what problem I'm dealing with.
Thanks in advance, Tomas

채택된 답변

Jarrod Rivituso
Jarrod Rivituso 2011년 5월 25일
Sounds like you just need some string concatenation...
for i = 1:length(vector)
block2AddSrc = ['library/' vector{i}];
block2AddName = ['cas/Name' num2str(i)];
addblock(block2AddSrc,block2AddName);
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Foundation and Custom Domains에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by