Simulink model: Invalid data type for root level port

조회 수: 14 (최근 30일)
Nafalai
Nafalai 2021년 11월 17일
댓글: Andy Bartlett 2025년 4월 3일
Hi!
I am developping a Simulink model calling another model which is composed of 12 "In" blocks and 4 "Out blocks".
One of the "In" block takes for input a matrix.
The called model calls this variable ("REEC") as such:
And my model calls this variable as such, also with an "In" port block and a Data Type Conversion, from double to single.:
I initialised my input variable "input_REEC" to be a 51x43 double matrix and added it to the input tab in Simulation > Model Configuration Parameters > Data Import/ Export
  1. If I run my simulation as such (input as double then converting it to single), I get the following error:
Invalid data type for root level port 'test_new_version_model_Switch/REEC' external data.
The root level input port is set to use data type 'single' but the external data is an array of type 'double'.
To load external data of non-double data type, change the external input to use structure format,
timeseries format, or disable loading of external input.
Loading of external inputs is disabled by going to the Simulation menu and selecting Configuration Parameters.
On the Data Import/Export page, locate the Load from workspace group and uncheck the Input checkbox.
2. If I run the simulation without the data type conversion (input as double and leaving it as such), I get the exact same error
Invalid data type for root level port 'test_new_version_model_Switch/REEC' external data.
The root level input port is set to use data type 'single' but the external data is an array of type 'double'.
To load external data of non-double data type, change the external input to use structure format,
timeseries format, or disable loading of external input.
Loading of external inputs is disabled by going to the Simulation menu and selecting Configuration Parameters.
On the Data Import/Export page, locate the Load from workspace group and uncheck the Input checkbox.
3. If I run the simulation with first transforming the input_REEC from double to single before starting the simulation (input_REEC = single(input_REEC), I get the error:
Unsupported input format. Available formats include: (1) a double non-complex matrix, (2) a structure with
or without time, (3) a MATLAB timeseries object, (4) a structure with MATLAB timeseries objects at all
leaves (for bus input), (5) a Simulink.Timeseries object, (6) a Simulink.TsArray object (for bus input).
All formats require the data to be finite (not Inf or NaN).
Would anybody know how to solve this by any chance?
Thank you very much!

채택된 답변

Andy Bartlett
Andy Bartlett 2021년 11월 17일
편집: Andy Bartlett 2021년 11월 17일
I suspect your inport "REEC" is not explicitly specifying its data type and is inheriting data type single via Simulink underspecified data type propagation rule.
To see the actual data type for REEC, go to information overlays and turn on "Base Data Types".
I suspect that will show something like this.
If so, you need to explicitly set the data type of the root inport to agree witht the data type you are feeding in from external data.
FYI: If you open the model's configuration parameters dialog (Ctrl-E) and search for "underspecified", then you'll find a diagnostic you can set to "warning" to alert you to underspecified data types.

추가 답변 (1개)

MAHENDRAN A
MAHENDRAN A 2025년 4월 3일
I've tried this solution, but same error. Note : Im doing MIL simulation, and getting this error
Invalid data type. The model is configured to load its root level ports from the workspace. These external inputs have data type 'double'. This data type does not agree with the data type, 'DrvrCmndWndMtnCtlLF_PWE1_idt', that is being set for this root level port.
  댓글 수: 1
Andy Bartlett
Andy Bartlett 2025년 4월 3일
Track down what 'DrvrCmndWndMtnCtlLF_PWE1_idt' is defined to be.
Maybe defined in MATLAB base workspace.
Maybe defined in the Simulink models workspace (viewable via model explorer).
Maybe defined in a Simulink Data Dictionary used by your Simulink model.
Is the definition of DrvrCmndWndMtnCtlLF_PWE1_idt something simple like single or something complicated like a Bus. Once you know what it is you're better positioned to figure out how to solve the error.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Sources에 대해 자세히 알아보기

제품


릴리스

R2014b

Community Treasure Hunt

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

Start Hunting!

Translated by