Dimensions error between data and bus definition when using "From File" block

2 次查看(过去 30 天)
I'm trying to use From File block to read a .mat file with timeseries data into my workspace. I have tried to closely follow the instructions at Load Data Using the From File Block. But after defining the bus and mat file into the workspace, I get Block error when compiling
> Error:Diagnostic reported from block 'untitled/From File'
Caused by:
Inconsistent port dimensions for the data in the variable 'anemoData' in file 'anemoA.mat' specified for From File block 'untitled/From File'. Field 'anemoData.AWS.signal' of the structure specified in this variable indicates that the dimensions are [1x1]. The element dimensions are set to [1] by the bus object specified for the From File block "Output data type" parameter.
But the dimensions of defined bus and timeseries data look exactly the same to me as in the official documentation page.
To Keep things simple, I only have From File block in my model
And this is the type/bus definition
Also, attached is the anemoA.mat file that I'm trying to read into the workspace

回答(1 个)

Divyajyoti Nayak
Divyajyoti Nayak 2025-2-26
Hi @Akash,
The error you are receiving is because the datatypes of the signals in the 'anemoA.mat' file and in the bus definition don't match. By default the data type of the signals in the bus are defined as 'double' (whose dimension is 1), while the signal in the mat file are of type 'timeseries' (dimension [1x1]), hence the error.
This can be fixed by defining the bus elements to be of type 'timeseries'. Here's some documentation and sample code to help you out:
elems(1) = Simulink.BusElement;
elems(1).Name = 'signal';
elems(1).DataType = 'timeseries';

类别

Help CenterFile Exchange 中查找有关 Sources 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by