problem with automized add_block destinations
9 次查看(过去 30 天)
显示 更早的评论
hello,
I am using the add_block function to automatize the creation of a model in simulink. I have stored the block names in a column of a table data, i would like to add the blocks and automatically change their names according to the string data of the table. Here is the code:
nL = numel(data.X)
for i=1:nl
h=add_block('MyLibrary/BlockName' , ['MyModel/',data.Names(i)])
end
here is the error message:
"Invalid destination block specification."
data.Names is a string column of the table data. I have tried using another column of the table
for i=1:nl
h=add_block('MyLibrary/BlockName' , ['MyModel/',num2str(data.X(i))])
end
and this works perfectly! What i am missing? please help! Thank you all!
4 个评论
Sulaymon Eshkabilov
2020-5-8
you are accessing to your stored created block names in strings via their index numbers. That is it.
采纳的回答
Ameer Hamza
2020-5-8
编辑:Ameer Hamza
2020-5-8
Change the line to this
h=add_block('MyLibrary/BlockName' , ['MyModel/',char(data.Names(i))])
%^ add char here
6 个评论
更多回答(1 个)
Sulaymon Eshkabilov
2020-5-8
you are accessing to your stored created block names in strings via their index numbers. That is it.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 String 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!