フィルターのクリア

Saving Simulink variable to Matlab workspace

8 ビュー (過去 30 日間)
Kris
Kris 2012 年 6 月 4 日
コメント済み: Kaustubha Govind 2014 年 8 月 29 日
Hello,
With the 'to workspace' block i want to write values to the matlab workspace. I load in a value from workspace (from an array i extruded from excel). Each step i want to save this value that i take from the workspace to the variabel A:
So if it at step 1 in the array the value is 4. I want to write this value of 4 to the variabel A. At step to the value is 10, so i want the 4 to be replace by 10.
While doing this i experience the following problems.
The first few steps (4 steps) the variabel a just keeps the value 0 (i set the ammount of date to save to 1 instead of inf as i only need one value). Sometimes i get the correct value. Sometimes i get the value of the step before.
What am i doing wrong?
Kind regards,
Kris
  2 件のコメント
Ilham Hardy
Ilham Hardy 2012 年 6 月 4 日
Are you using "From workspace" to load the value from the workspace?
Kris
Kris 2012 年 6 月 4 日
Yes. I opened excel in my matlab workspace. Next i put my data into an array. And at last i imported my data into Simulink workspace by the From workspace block.

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

回答 (1 件)

Kaustubha Govind
Kaustubha Govind 2012 年 6 月 5 日
AFAIK, the "To Workspace" block logs the signal at each time-step. At the end of simulation, there is an array/structure with signal values as well as the time-stamps corresponding to each value. It's not clear to me how you log a single scalar value using this block.
Also, note that you cannot expect the "To Workspace" block to update the workspace immediately (during simulation). It is only guaranteed that the variable will be ready in the workspace at the end of simulation. Please see the second paragraph of my answer here about why I think this guarantee doesn't exist.
In general, you need to follow the technique in this section for what you require: Accessing Block Data During Simulation.
  2 件のコメント
Nancy
Nancy 2014 年 8 月 28 日
The link "Accessing Block Data During Simulation" is broken--perhaps going back to an older version of Simulink. Do you what would be the corresponding section in the R2014a documentation? I can't find a section with that title, and it sounds like it could be relevant to my problem. Thanks!
Kaustubha Govind
Kaustubha Govind 2014 年 8 月 29 日

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

カテゴリ

Help Center および File ExchangeSimulink Environment Customization についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by