How can I change the variable name of "to workspace" dynamically ?
2 views (last 30 days)
Show older comments
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".
0 Comments
Accepted Answer
Fangjun Jiang
on 15 Dec 2011
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')]);
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!