Multidimensional data load in simulink

조회 수: 5 (최근 30일)
Oindri Mazumdar
Oindri Mazumdar 2023년 6월 13일
답변: Sharad 2023년 6월 15일
I have matlab data structures where for every time stamp (frame in our case) , there are multiple data points (rows). Every data point is having multiple column/attributes.
Simulink takes time versus signal data. How can I re-structure my data to fit to simulink requirements. Am I missing something here ?

답변 (1개)

Sharad
Sharad 2023년 6월 15일
Hi,
In order to restructure your data to fit Simulink requirements, you can follow these steps:
  • Ensure that the multidimensional data is stored in a suitable MATLAB data format (eg- M x N matrix).
  • Add a MATLAB function block to the Simulink model (restructuring of data can be done in this block).
  • Adjust the input and output ports.(for eg - if there are M timestamps and N data points for each timestamp, the input port can be set to 'M x N' and output port to 'T x 1', where T = M * N.
% the input and output sizes can be calculated
[M, N] = size(data);
T = M * N;
  • Code the MATLAB function:
function out = restructureData(data)
% reshape the vector to T x 1 matrix
values = reshape(data, [], 1);
end
  • Connect the "From Workspace" block to the input port of the MATLAB Function block, and connect the output port of the MATLAB Function block to the rest of your Simulink model.
  • Configure the "From Workspace" block to load the multi-dimensional data. Set the "Data Type" as a matrix and provide the appropriate variable name, such as 'data', in the "Variable name" field.

카테고리

Help CenterFile Exchange에서 Interactive Model Editing에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by