24小时热门版块排行榜    

查看: 4262  |  回复: 4

林传统

铜虫 (初入文坛)

[求助] 想把m文件在simulink 中的调用,我用的是matlab function 模块。

RT   我的m文件的代码是function  h_vs= fcn(T_s)
B13=  [-575.520*10^-4  117.700*10^-5   491.369*10^-8      782.701*10^-2   -815.233*10^-3      256.383*10^-4     149.856*10^-1   -209.283*10^-2];
a=zeros(1,8);
for i=1:8
    a(i)=B13(i);
end
coder.extrinsic('syms');
syms  h_vs u v;
T_s=T_s+273.15-61;
v=T_s-203.15;   
u=(h_vs-350)^0.5-2.24076;
x=solve(u^3+a(1)*u^2*v+a(2)*u*v^2+a(3)*v^3+a(4)*u^2+a(5)*u*v+a(6)*v^2+a(7)*u+a(8)*v,h_vs);
y=max (real (double (subs(x))));
h_vs=y;
end
  复制到matlab function中想要调用却出现如下8个错误:

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: MATLAB Function | Category: Coder error
Undefined function or variable 'h_vs'. The first assignment to a local variable determines its class.

Function 'MATLAB Function' (#71.303.307), line 12, column 4:
"h_vs"
Launch diagnostic report.
Component: MATLAB Function | Category: Coder error
Undefined function or variable 'u'. The first assignment to a local variable determines its class.

Function 'MATLAB Function' (#71.334.335), line 13, column 9:
"u"
Launch diagnostic report.
Component: MATLAB Function | Category: Coder error
Undefined function or variable 'x'. The first assignment to a local variable determines its class.

Function 'MATLAB Function' (#71.443.444), line 14, column 27:
"x"
Launch diagnostic report.
Component: MATLAB Function | Category: Coder error
Undefined function or variable 'y'. The first assignment to a local variable determines its class.

Function 'MATLAB Function' (#71.455.456), line 15, column 6:
"y"
Launch diagnostic report.
Component: MATLAB Function | Category: Coder error
Errors occurred during parsing of MATLAB function 'MATLAB Function'
Component: MATLAB Function | Category: Coder error
Errors occurred during parsing of MATLAB function 'MATLAB Function'
Component: Simulink | Category: Block error
Error occurred in 'sim_hvs/MATLAB Function'.
Component: Simulink | Category: Block error

图片在附件;
求大神解决

想把m文件在simulink 中的调用,我用的是matlab function 模块。
捕获.PNG
回复此楼
111
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
祝福
2楼2016-08-27 23:02:46
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
祝福
3楼2016-08-28 00:17:19
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
祝福
4楼2016-08-28 00:53:44
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

Andrew_Yao

新虫 (小有名气)

问题解决了吗?
5楼2020-06-07 20:57:06
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 林传统 的主题更新
信息提示
请填处理意见