i need to have a variable which i can access into and assign to during the simulation in simulink. any suggestions please?

5 次查看(过去 30 天)
i am implementing a motion planning algorithm in simulink, I have to collect the successful nodes in a multi dimensional array on the go during simulation and also be able to access the nodes. Currently the only options i came across are
  1. Initializing, lets say 500x2 array in matlab workspace,then use it as a initial value in data store memory block in simulink. I also declared the data store memory block as global so that i can access it into other function's work space. Every time i want to add a node i read the data store memory value and then write into it by assignment from a matlab function block.
  2. using persistent variables within the scope of matlab function blocks.
I am still trying to implement the above two ideas. But i am a bit skeptic and i am seeking some experts advice here for better options.
Also, I will be generating vehicle waypoints which will be an array of size nx2 at every iteration which i need to store somewhere accessible during simulation. If not the whole array at least the end point of the waypoint array, i need to be able to use for every next iteration (as the rest of the waypoint array values can be written to matlab workspace which i can access after the simulation is complete).
When i implemented the algorithm in .m script file i used cell array to store the array of waypoints generated at every iteration.

回答(1 个)

Nishant Gupta
Nishant Gupta 2020-5-26
You can use 'To workspace' block, it might help you. Refer to the following link for its documentation:
  2 个评论
giridhar vitta-bukka
'To workspace' block doesnt solve my problem. as i mentioned in my question clearly that i need to collect values in an array on the go during simulation and also be able to access these values in other function blocks,subsystems etc
I used "Data store memory" block and it works! but my question was to get some insights on my approach and suggest better ideas.
If i am not clear in my question i can explain it in detail again.

请先登录,再进行评论。

类别

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