how to access array of structures in simulink which are loaded from work space using preload fcn, updating the structure values in runtime and these updated values to be implemented in model?

조회 수: 2 (최근 30일)
code :
p(1).x = 0; p(1).y = 0; p(1).name='one'; p(2).x = 1; p(2).y = 1; p(2).name='two';
I know to save variables in .m file during simulation, and also loading that .m file in simulink -> model properties -> preload function
If we load the model, preload function will be executed only once during start of simulation, but i need to change values continuously in workspace that should be dynamically updated in simulink model. so will this preload function gives these updated values to simulink at runtime? i tried but didnt get, so is there any other way for this? how to get these updated variables in simulink model?
then how to access the array of structure in simulink model? I need to use array of structures in simulink, how to access and use it in models?
  댓글 수: 2
Kaustubha Govind
Kaustubha Govind 2013년 8월 29일
Could you clarify whether you intend to use the structure as a signal or as a parameter in Simulink?
Dhaklesh kumar
Dhaklesh kumar 2013년 9월 2일
편집: Dhaklesh kumar 2013년 9월 2일
It is a parameter like C language structure, but it will not have time parameter, i need to access the values which are in that array of structure in simulink, can you explain me how to get values from that array of structure in simulink.

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

채택된 답변

Vishal Rane
Vishal Rane 2013년 8월 28일
Use:
set_param( MdlName, 'PreloadFcn', YourFunction);
this works during simulation as well.
Similarly you can set the StopFcn to save the data generated during simulation to a mat file.
  댓글 수: 1
Dhaklesh kumar
Dhaklesh kumar 2013년 8월 29일
편집: Dhaklesh kumar 2013년 8월 29일
Thanks for ur reply. but i have updated the question, so can use check the updated query and give the answer.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by