필터 지우기
필터 지우기

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!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulink Environment Customization에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by