Saving Simulink variable to Matlab workspace
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Kaustubha Govind
am 5 Jun. 2012
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 Kommentare
Nancy
am 28 Aug. 2014
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
am 29 Aug. 2014
Siehe auch
Kategorien
Mehr zu Simulink Environment Customization finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!