How can I change the variable name of "to workspace" dynamically ?

4 次查看(过去 30 天)
My question was showed in a picture. https://www.opendrive.com/files/?Ml8yOTY2NjJfa0Z4Z3E fig1 is a block I have established.fig2 is the input panel(NUM).In a system I need many A block,but has a"To Workspace"in A will error. I hope if I give a NUM is "1" ,the "To Workspace" can change its Variable name into "A_out1" automatically,and if the NUM input is "2" it can be changed into "A_out2".

采纳的回答

Fangjun Jiang
Fangjun Jiang 2011-12-15
I would recommend you go back to your previous question and follow the advice regarding data logging. My comment regarding "mask parameter could be a workaround" is really for the sake of argument. Your approach of putting a "To Workspace" block inside a customized library block is non-typical. It can be made to work with mask parameter but it is a stretch.
However, to prove it can be done, I'll show you the method here. Still, I strongly recommend that you use other data logging method. The worst case, is that you can choose not to put the "To Workspace" block inside the customized library block. Rather, you can put the "To Workspace" block outside of the reference block in the model.
Assume you added a mask parameter called 'VarNum' which is an 'edit' type, and the name of the "To Workspace" block inside is still called "To Workspace", you can add the following line in the "Dialog callback" of the mask parameter 'VarNum'.
set_param([gcb,'/To Workspace'],'VariableName',['A_Out',get_param(gcb,'VarNum')]);
  1 个评论
li xinjun
li xinjun 2011-12-15
Thank you for your help again.I have read your previous answer.But my English is not very well,so I can't understand it well.Because I must finish my assignment in time,so I hope a easier workaround.Thank you for your help.I will carefully study your previous answer.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by