Loading and saving huge matrices in Simulink

12 ビュー (過去 30 日間)
Brage Mothes
Brage Mothes 2019 年 3 月 20 日
Hello,
I am working with a reinforcement learning model in Simulink. For the memory i need to use huge 6D matrices.
Currently I create these matrices in Matlab and load them into my Matlab Function Block in Simulink using the following code:
persistent Q
if isempty(Q)
Q = evalin('base', 'q8');
end
But this is very time consuming, and i have problems saving the matrix back into my Matlab workspace afterwards.
Anyone know of an easier way of working with big matrices in Simulink, that can be loaded and saved?
Examples are greatly appreciated!
Thanks!

回答 (2 件)

Fangjun Jiang
Fangjun Jiang 2019 年 3 月 20 日
Can't use .mat file? Try Simulink Data Dictionary.
  2 件のコメント
Brage Mothes
Brage Mothes 2019 年 3 月 20 日
Maybe, but how do i do this and how do i read from and write to this from a Matlab Function Block?
Fangjun Jiang
Fangjun Jiang 2019 年 3 月 21 日
If your current approach works but slow, the first thing I would try is to save the matraces into a .mat file. Next time, you can use load() instead of evalin() to load the data. I am not sure what you mean by "have problems saving the matrix back into my Matlab workspace afterwards".
The next thing is try SLDD. Go to File->Model Properties->Link to Data Dictionary. Once you finished, just think of the data is loaded from the .sldd file rather than the .mat file.

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


Emmanouil Tzorakoleftherakis
Emmanouil Tzorakoleftherakis 2019 年 4 月 2 日
On a separate note, it looks like you are implementing Q-learning (?). Q-learning uses tables, which do not scale well when your problem is high-dimensional. Maybe switching to a function approximator (e.g. neural network) would help with scaling.
You could also use some of the built-in reinforcement learning algorithms from Reinforcemen Learning Toolbox (e.g. DQN).
Hope this helps.

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by