Multidimensional data load in simulink

3 visualizzazioni (ultimi 30 giorni)
Oindri Mazumdar
Oindri Mazumdar il 13 Giu 2023
Risposto: Sharad il 15 Giu 2023
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 ?

Risposte (1)

Sharad
Sharad il 15 Giu 2023
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.

Prodotti


Release

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by