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 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