フィルターのクリア

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

5 ビュー (過去 30 日間)
li xinjun
li xinjun 2011 年 12 月 15 日
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 Center および File ExchangeProgrammatic Model Editing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by