Load array from .mat file in Matlab System
41 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am curently coding a Matlab System for use in Simulink. I want to load two large arrays from a .mat file to be used in the Matlab System. Because of that, I figured I could load the data like this in the resetImpl function.
function resetImpl(obj)
% ...
obj.arrays = load('arrays.mat');
% ...
end
However, this results in the error:
Function 'load' can only be used as the right-hand side of a simple assignment to a struct or array variable without subscripting.
How can I load a .mat file in a Matlab System?
2 comentarios
Walter Roberson
el 1 de Ag. de 2022
Editada: Walter Roberson
el 1 de Ag. de 2022
load() storing into a simple variable . Extract fields from the struct and store into obj.
Note that this requires that you be using System Objects https://www.mathworks.com/help/simulink/slref/matlabsystem.html
Respuestas (1)
Abderrahim. B
el 1 de Ag. de 2022
Hi!
I believe you are building a model in Simulink! If this is the case, you don't need to write a function for loading data:
hope this helps
1 comentario
Walter Roberson
el 1 de Ag. de 2022
From File is restricted to creating signal objects . If you needed to do something such as load a covariance matrix for matrix multiplication then From File would not be suitable .
Ver también
Categorías
Más información sobre Create System Objects en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!