One variable, two 'To Workspace' blocks simulink

Hello, is there a way to update single struct variable using two or more 'To Workspace' blocks at different locations in simulink (2017b) ??

2 件のコメント

Fangjun Jiang
Fangjun Jiang 2020 年 7 月 2 日
what do you mean "update"?
"struct" data type is not supported in Simulink.
Manu Agarwal
Manu Agarwal 2020 年 7 月 2 日
Actually, in my simulink model I am using 'To Workspace' block to save data of some of the output signals in variable 'Res'. Now, with "update" I mean that I want to save data of some other signals as well under the same variable 'Res' but using different 'To Workspace' block. Here, my question is, is that possible??
In 'To Workspace' block there is an option to save in struct format. (Save formate -> Structure With Time), this is what I am using.
Thanks in advance.

サインインしてコメントする。

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2020 年 7 月 2 日

0 投票

"Res" is the variable created in the based workspace after simulation is done to log your simulation data
  1. You can't have two "To Workspace" blocks in the model with the same variable name "Res".
  2. You can log more than one signals to the same variable "Res" with just one "To Workspace" block. To do that, use a Mux block or Bus Creator block to combine all those signals together and then feed it to the "To Workspace" block. Observe the "Res" data after simulation to figure how to access the data inside it.

4 件のコメント

Manu Agarwal
Manu Agarwal 2020 年 7 月 2 日
I am already using Mux, problem is that model is huge and I cannot drag every required signal to the place where 'Mux' and 'To Workspace' block is because the model has many layers in the form of subsystems.
Fangjun Jiang
Fangjun Jiang 2020 年 7 月 2 日
In model configuration parameters, Data Import/Export, check "single simulation output". It will combine all the "To Workspace" variable into one structure or object. I think this can help you.
Manu Agarwal
Manu Agarwal 2020 年 7 月 2 日
I just tried this, it is combining the two variables (say Res and Res1) from two 'To Workspace' blocks into one variable 'out'. I can access the data in 'Res' and 'Res1' through 'out.Res' and 'out.Res1'. But what I precisely need is to append the data of Res1 to Res but by not connecting them to one 'To Workspace' block.
Fangjun Jiang
Fangjun Jiang 2020 年 7 月 2 日
Don't quite understand the use case of your particular saving format.
  1. Do post processing, combine out.Res and out.Res1 into out.Res
  2. Use global Goto/From block to avoid signl routing but Mux all the needed signals together
  3. Not to use "To Workspace" block, use individual signal logging by setting signal line properties, then post processing, combine signals by name, i.e. out.FrontWheelSpeed and out.RearWheelSpeed to out.WheelSpeed

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangePrepare Model Inputs and Outputs についてさらに検索

製品

リリース

R2017b

質問済み:

2020 年 7 月 2 日

コメント済み:

2020 年 7 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by