米脂
方法: 命令行窗口:global B;B=1;这时matlab workspace (base workspace)里有了B, 然后 simulink 的matlab function 模块里代码是:function y = fcn(u)%#codegenglobal B;y = u+B;其实就是让输入加上这个全局变量的值,结果仿真时出错信息是:1.Global declaration not resolved to a Data Store Memory block registered via the Ports and Data Manager.Function 'MATLAB Function' (#24.45.46), line 4, column 7:"B"Launch diagnostic report.2.Errors occurred during parsing of MATLAB function 'MATLAB Function'(#23)3. Error due to multiple causes.Errors occurred during parsing of MATLAB function 'MATLAB Function'(#23)Error in port widths or dimensions. Output port 1 of 'M_function_try/MATLAB Function/u' is a one dimensional vector with 1 elements.