Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 工程数学软件 > MATLAB论坛
MATLAB论坛 一切MATLAB相关问题在此讨论。
回复
 
主题工具 显示模式
旧 2010-03-29, 21:25   #1
lxl723
初级会员
 
注册日期: 2010-03-28
帖子: 3
声望力: 0
lxl723 正向着好的方向发展
帖子 求助:帮我看看哪出错了?

小弟想用embeded matlab function 模块,里面代码如下:
function[p,v,h,s]=tx(t,x)

p=psaturation(t);
[vwater,hwater,swater]=ptwater(p,t);
[vsteam,hsteam,ssteam]=ptsteam(p,t);
v=vwater+x*(vsteam-vwater);
h=hwater+x*(hsteam-hwater);
s=swater+x*(ssteam-swater);

其中p=psaturation(t);
vwater,hwater,swater]=ptwater(p,t);
[vsteam,hsteam,ssteam]=ptsteam(p,t);
是三个M函数,运行时正确无误,但当运行这个embeded matlab function 模块时出现以下错误:
1,Expected either a logical, char, single, or double.
Found an mxArray. mxArrays are returned from calls to the MATLAB interpreter and are not supported inside expressions. They may be used on the right-hand side of assignments and as arguments to MATLAB calls.

Function 'tx' (#82.131.137), line 6, column 13:
"vsteam"
2,Expected either a logical, char, single, or double.
Found an mxArray. mxArrays are returned from calls to the MATLAB interpreter and are not supported inside expressions. They may be used on the right-hand side of assignments and as arguments to MATLAB calls.

Function 'tx' (#82.159.165), line 7, column 13:
"hsteam"

3,Expected either a logical, char, single, or double.
Found an mxArray. mxArrays are returned from calls to the MATLAB interpreter and are not supported inside expressions. They may be used on the right-hand side of assignments and as arguments to MATLAB calls.

Function 'tx' (#82.187.193), line 8, column 13:
"ssteam"
4,Errors occurred during parsing of Embedded MATLAB function 'tx'(#82)
5,Embedded MATLAB Interface Error: Port width mismatch. Input port "x"(#89) expects a scalar. The signal is a one dimensional vector with 1 elements.

不知道是不是能这样调用函数的原因?望高手解答下!先谢谢了!
lxl723 当前离线   回复时引用此帖
旧 2010-04-01, 09:16   #2
xiaoyaoshanzi
初级会员
 
注册日期: 2010-04-01
年龄: 39
帖子: 1
声望力: 0
xiaoyaoshanzi 正向着好的方向发展
默认 回复: 求助:帮我看看哪出错了?

在应用函数时应该
p=@psaturation(t);、、、、、、、
xiaoyaoshanzi 当前离线   回复时引用此帖
旧 2010-04-01, 13:28   #3
lxl723
初级会员
 
注册日期: 2010-03-28
帖子: 3
声望力: 0
lxl723 正向着好的方向发展
帖子 回复: 求助:帮我看看哪出错了?

首先谢谢楼上的回答,我试了下,还是报错,不过已找到解决办法,即把调用函数的代码写在此模块里就没有问题,和C的用法很相似。
lxl723 当前离线   回复时引用此帖
回复

主题工具
显示模式

发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码



所有时间均为北京时间。现在的时间是 22:20


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.