Using global variables in Embedded Matlab function in simulink

3 次查看(过去 30 天)
Hi,
I am using data store memory blocks in conjunction with global variables to use global variables in embedded matlab function in simulink. I have 4 global variables and therefore I have 4 data storage memory blocks in my simulink model. However, when I ran my simulation, the values of the global variables were not taken from the data storage block and instead I got a warning which says:
Warning: The block 'Embedded MATLAB Function' is reading from element 0 of the data store 'Data Store Memory' before any blocks have written to this memory in a minor time step at time 400.0
400 - is my simulation time.
I do not understand the reason why I am receiving this message and the reason for the values of the global variables not being updated from the data storage :(
It would be great if any of you could advice or suggest me on this.
Thanks
  3 个评论
TAB
TAB 2011-9-28
I am not confident, but try to write the Data store Memory with 'Data store write' block, see its work or not.

请先登录,再进行评论。

采纳的回答

TAB
TAB 2011-9-28
Hi Muthappa
Make sure that you are ensuring following steps while using global variables with embedded matlab.
[EDITED]
Data Store memory is used to hold the data value only. To write the data to it a Data Store Write block with same name is required. Similarly, to read the data from it a Data Store read is required.
You are reading from a Data Store memory block through global variable in EML function, so it is necessary to write some value in the memory first. Use Data Store Write block with the same name and write some value to it.
  • I tried first without Write block and got same warning as you.
  • I added Data store write block, and model runs without warning giving expected output.
  4 个评论

请先登录,再进行评论。

更多回答(1 个)

Fangjun Jiang
Fangjun Jiang 2011-9-28
Those are just warnings. If you are sure that you don't write to the memory as often as you read it, you can disable the warning.
Go to Simulink model, select menu Simulation->Configuration Parameters...->Diagnostics->Data Validity, in the "Data Store Memory Block" section.
  1 个评论
Muthappa
Muthappa 2011-9-28
Thank you Jiang,
Its definitely useful to me as such warnings would not let me read my output clearly.
Have a nice day!!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by