What is an alternative to cell arrays in simulink models?

조회 수: 3 (최근 30일)
Bernardo Hernandez
Bernardo Hernandez 2019년 12월 5일
답변: SaiDileep Kola 2020년 2월 14일
I understand from the documentation that I cannot load a cell array from workspace into a simulink model. What is a good alternative then?
I have a cell array in which each element is a matrix filled with numbers. All matrices are (or may be) of different dimensions, which is why I originally stored them in a cell array. In the simulink model I would like to use this cell array as an input to a matlab function block. Within this matlab function block certain preprocessing operations are performed in order to selectone or more elements of this cell array to be employed in the rest of the function.
Thanks for the help.

답변 (1개)

SaiDileep Kola
SaiDileep Kola 2020년 2월 14일
Way to achieve this is to save cell in to .mat file and load that file in the MATLAB script in Simulink which will be read here as struct and access accordingly in the script, this way you can read cells in workspace
Ex:
x = {1,2,[3 5]};
save('pqfile.mat','x');
%Matlab script In the simulink
function y = fcn(u)
x = load('pqfile.mat');
y = x.x{3}*u;

카테고리

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

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by