What can I use instead of 'load' in Simulink?
2 次查看(过去 30 天)
显示 更早的评论
I have a Simulink model to simulate motion in water. I also have hundreds of .mat files with 3D flow field data (u, v, w in m/s). The flow field files are sequential in time, starting at time = 0 and with a time resolution of 0.2s (time = 0 => file_1, time = 0.2 => file_2 etc.). Depending on the simulation time I want to read the 3D flow field data from the corresponding file for interpolation, in both space and time (time = 0.15 => interpolation in time between file_1 and file_2).
In Matlab this is straight forward, then I'm able to use the 'load' function (and/or 'matfile' function) to read the data. When implementing a Matlab Function in Simulink I'm no longer able to use either the 'load' or the 'matfile' function to read the data.
How can I go forward from here?
- It says here http://se.mathworks.com/help/matlab/ref/load.html that the 'load' function should work if assigned as a struct, but I cannot get it to work. Maybe this is due to my old Matlab version, r2013b.
- I do not have to use a Matlab Function block, if there is another way to read the data during simulation.
- I have tried using callbacks, then I'm allowed to use the 'load' function, but they only executes once and not for every timestep during the simulation. *
- I have tried to figure out if it's possible to use the blocks 'From File' and 'To File' but without luck, my Simulink skills aren't as good as my Matlab skills.
- Due to the size of the files I cannot load them once in advance to Workspace, it will fill up the memory.
The .mat files contain a struct with the desired data (flow field; u, v, w) as follows:
field =
Single: [1x1 struct]
Var: [1x1 struct]
>> field.Single
ans =
U: [256x256x128 single]
V: [256x256x128 single]
W: [256x256x128 single]
T: [256x256x128 single]
>> field.Single.U(1,1,1)
ans =
0.6148
Coder error from Simulink:
Report, mouse pointer over 'load':
Do you have any suggestions?
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sources 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!