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

조회 수: 3 (최근 30일)
Akash
Akash 2025년 2월 25일
답변: Divyajyoti Nayak 2025년 2월 26일
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