Using global variables in Embedded Matlab function in simulink

5 visualizzazioni (ultimi 30 giorni)
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 Commenti
TAB
TAB il 28 Set 2011
I am not confident, but try to write the Data store Memory with 'Data store write' block, see its work or not.
TAB
TAB il 28 Set 2011
Can you post code of your embedded matlab function block.

Accedi per commentare.

Risposta accettata

TAB
TAB il 28 Set 2011
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 Commenti
Muthappa
Muthappa il 28 Set 2011
Thank You Tabrez. It works for me now :)
Have a nice day!!

Accedi per commentare.

Più risposte (1)

Fangjun Jiang
Fangjun Jiang il 28 Set 2011
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 Commento
Muthappa
Muthappa il 28 Set 2011
Thank you Jiang,
Its definitely useful to me as such warnings would not let me read my output clearly.
Have a nice day!!

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by