Using global variables in Embedded Matlab function in simulink

7 ビュー (過去 30 日間)
Muthappa
Muthappa 2011 年 9 月 28 日
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 日
Can you post code of your embedded matlab function block.

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

採用された回答

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 件のコメント
TAB
TAB 2011 年 9 月 28 日
See Edited part of this answer.
Muthappa
Muthappa 2011 年 9 月 28 日
Thank You Tabrez. It works for me now :)
Have a nice day!!

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

その他の回答 (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 Center および File ExchangeSimulink Functions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by