【Simulink】报错:Size mismatch (size [2 x 1] ~= size [1 x 1]). The size to the left is the size of the l

简介: 【Simulink】报错:Size mismatch (size [2 x 1] ~= size [1 x 1]). The size to the left is the size of the l

版本:Matlab2019b

背景信息:

我在 Simulink 里面的 stateflow 里面,写了一个 Matlab Function,参照了实验室往届师兄的代码,同样都是单输入单输出函数,但是用的变量大小不一样。

报错信息:

直接套用函数果然出现了问题。

Simulink does not have enough information to determine output sizes for this block. If you think the errors below are inaccurate, try specifying types for the block inputs and/or sizes for the block outputs.
Component:Stateflow | Category:Coder error
Size mismatch (size [2 x 1] ~= size [1 x 1]).
The size to the left is the size of the left-hand side of the assignment.
Function 'thd_cal' (#135.1133.1141), line 47, column 1:
"thd_temp"
Launch diagnostic report.
Component:Stateflow | Category:Coder error
Error while generating code for chart Chart.
Component:Stateflow | Category:Coder error
Error while generating code for chart Chart.
Component:Simulink | Category:Model error
Error occurred in 'MPC_SPI6/Chart'.
Component:Simulink | Category:Model error

看了网上的解决方法,比如修改变量名,还是没能解决。

解决方法:

Size mismatch (size [2 x 1] ~= size [1 x 1]).
The size to the left is the size of the left-hand side of the assignment.
Function 'thd_cal' (#135.1133.1141), line 47, column 1:
"thd_temp"

从报错信息可以看出,变量 thd_temp 有问题,原本是 size [2 x 1] ,但运行结果是 size [1 x 1] .

根据报错信息提示,修改变量大小。

点击 MODELING -> Model Explorer

可以看到各种模块变量的信息,在 Stateflow “Chart” 下面除了 State,还有自己写的 Matlab Function “thd_cal”

点击"thd_cal",修改里面变量大小

根据报错信息提示,把 [2, 1] 改成 1 即可。

这时候再运行,就没有 Size 报错了。

相关文章
|
6月前
GEE错误——Layer error: Image.connectedPixelCount: Segment size calculation on floating point bands is n
GEE错误——Layer error: Image.connectedPixelCount: Segment size calculation on floating point bands is n
75 0
RuntimeError: Given groups=1, weight of size 64 128 1 7, expected input[16,
RuntimeError: Given groups=1, weight of size 64 128 1 7, expected input[16,
2936 0
|
5月前
|
区块链
max code size exceeded
max code size exceeded
62 6
|
6月前
|
关系型数据库 MySQL
MySQL【问题 02】报错 1709 - Index column size too large. The maximum column size is 767 bytes. 可能是最简单的方法
MySQL【问题 02】报错 1709 - Index column size too large. The maximum column size is 767 bytes. 可能是最简单的方法
211 0
|
索引
Result window is too large, from + size must be less than or equal to: [10000]
Result window is too large, from + size must be less than or equal to: [10000]
213 0
The size of tensor a (4) must match the size of tensor b (3) at non-singletonThe size of
The size of tensor a (4) must match the size of tensor b (3) at non-singletonThe size of
932 0
|
JSON 数据格式
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
515 0
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
|
TensorFlow 算法框架/工具
ValueError: Negative dimension size caused by subtracting 5 from 1 for ‘{{node le_net5/conv2d/Conv2D
ValueError: Negative dimension size caused by subtracting 5 from 1 for ‘{{node le_net5/conv2d/Conv2D
177 0
malloc(): corrupted top size
malloc(): corrupted top size
939 0
成功解决lightgbm.basic.LightGBMError: Parameter max_depth should be of type int, got “0.02“
成功解决lightgbm.basic.LightGBMError: Parameter max_depth should be of type int, got “0.02“