MATLAB Simulink仿真报错如下:
Index expression out of bounds. Attempted to access element 2. The valid range is 1-1.
More information
Function ' e2=dotx1d+k1e1-x2' (#45.31.32), line 3, column 12:
"2"
Launch diagnostic report.
Component: MATLAB Function | Category: Coder error
解决方法如下:
把上图中mux中的4改成[ 1 1 1 1]即可,然后成功运行不报错。[ 1 1 1 1]表示有4根数据线,每根数据线的数据个数依次为1、1、1、1。
具体原因未知,但是这样修改后可以完美运行。
参考文献:
Simulink中使用MATLAB function模块报错输入超出索引(“Index expression out of bounds”)