MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   求助:帮我看看哪出错了? (https://www.labfans.com/bbs/showthread.php?t=11123)

lxl723 2010-03-29 21:25

求助:帮我看看哪出错了?
 
小弟想用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.

不知道是不是能这样调用函数的原因?望高手解答下!先谢谢了!

xiaoyaoshanzi 2010-04-01 09:16

回复: 求助:帮我看看哪出错了?
 
在应用函数时应该
p=@psaturation(t);、、、、、、、

lxl723 2010-04-01 13:28

回复: 求助:帮我看看哪出错了?
 
首先谢谢楼上的回答,我试了下,还是报错,不过已找到解决办法,即把调用函数的代码写在此模块里就没有问题,和C的用法很相似。


所有时间均为北京时间。现在的时间是 12:51

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