声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 7601|回复: 14

[编程技巧] 请教??? One or more output arguments not assigned during call to '***'.

[复制链接]
发表于 2006-10-26 10:27 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
各位大虾 ,偶碰到这个问题n久也没弄明白怎么回事,请各位指点一下

哦,对了,补充一下,程序里所有的输出变量的值都能算出来,然后最后出现这个报错的

function CeqHE=Heater(HEObj)
%  Heater calculates the residual error of a  Heater block.
% Input: HEObj is a block with the following structure
%        HEObj = struct('T',[],'P',[],'Q',[],'Sin',[],'SoutL',[],'SoutV',[],'r1',[],'r2',[]);
%        T: Heater temperature (K);
%        P: Heater pressure (psi);
%        Q: Heater input duty (MJ/s);
%        Sin: Heater feed(s), stream structure;
%        SoutL: Heater liquid product, stream structure;
%        SoutV: Heater vapor product, stream structure;
% Output:CeqHE is the residual error of block HEObj;
%

% For DOF analysis reference:
% DOF = No.(Sin)*NV(Stream) + 2;  Degree of freedom;
% NFreeVar = No.(SoutL,SoutV)*NV(Stream) + 1;  No. of free variables;
Stream = struct('T',[],'P',[],'F',[],'C',[]);
SinL = Stream;
SinV = Stream;

disp(HEObj.Sin);
disp(HEObj.SoutL);
disp(HEObj.SoutV);

[SinV,SinL,K] = VL(HEObj.Sin,HEObj.r1,HEObj.Sin.T);

SinL.F = HEObj.Sin.F*HEObj.Sin.C'*K';
SinV.F = HEObj.Sin.F-SinL.F;

disp(SinL);
disp(SinV);
disp(K);

TBub = 290;
TDew = 310;

% NC: Number of components;

NC = length(HEObj.Sin.C);

% Calculation of the enthalpies of the feeds using srk function;
%  Temporarily,to be revised later;

%[Sin_K,SinL_H,SinV_H] = srk(HEObj.Sin.T,HEObj.Sin.P,SinL.C(:),SinV.C(:)); %MJ/kmol;43682458.1/1e6;

SinL_H  =  2;
SinV_H  =  3;


Sout_K   =  [.4 .3 .2 .3];
SoutL_H  =  4;
SoutV_H  =  5;



% Residual error between temperature and pressure state of the heater object and the product streams;
CeqF(1) = HEObj.SoutL.T-HEObj.T;
CeqF(2) = HEObj.SoutV.T-HEObj.T;
CeqF(3) = HEObj.SoutL.P-HEObj.P;
CeqF(4) = HEObj.SoutV.P-HEObj.P;

disp(CeqF);

% Residual error of Equilibrium equations
for i=1:NC
    CeqE(i) = - HEObj.SoutV.C(i) + Sout_K(i)*HEObj.SoutL.C(i);
    end

Sin   = HEObj.Sin;

SoutL = HEObj.SoutL;

SoutV = HEObj.SoutV;


T = SoutL.T;
if T<TBub
    SoutV() = 0;   
    CeqE = zeros(1,NC);
elseif T>TDew
    SoutL() = 0;     
    CeqE = zeros(1,NC);
end

disp(CeqE);
% Efficiency of the followings can be enhanced later by removing the original 'for' statement using vector operations
% Residual error of Mass balance equations;
for i=1:NC
   
    SumSinMi = Sin.F*HEObj.Sin.C(i);
   
    CeqM(i) = -SumSinMi + SoutL.F*HEObj.SoutL.C(i) + SoutV.F*HEObj.SoutV.C(i);
end   

disp(CeqM);
% Conditional Modeling %

% Residual error of Summation equations  
CeqSx = sum( HEObj.SoutL.C)-1;
CeqSy = sum( HEObj.SoutV.C)-1;
if T<TBub
     CeqSy = (sum(HEObj.SoutV.C)-1)*SoutV.F;
elseif T>TDew
     CeqSx = (sum(HEObj.SoutL.C)-1)*SoutL.F;
end

disp(CeqSx);
disp(CeqSy);
% Conditional Modeling %

% Residual error of entHalpy equations  % with potential problem

SumSinH = SinL.F*SinL_H + SinV.F*SinV_H;

CeqH = - SumSinH - HEObj.Q + SoutV.F*SoutV_H+ SoutL.F*SoutL_H;

disp(CeqH);
% Residual error of r

r1 = HEObj.r1;
disp(r1);
CeqSum1 = 0;
disp(CeqSum1);

r2 = HEObj.r2;
disp(r2);
CeqSum2 = 0;
disp(CeqSum2);

% Total residual errors of HEObj
CeqPA = [CeqF(:)' CeqM(:)' CeqE(:)' CeqSx CeqSy CeqH CeqSum1 CeqSum1];

disp(CeqPA);

程序就是这样的,执行到最后的disp(CeqPA)结果可以出的,然后就是报错……

[ 本帖最后由 sdzx112233 于 2006-10-26 10:40 编辑 ]
回复
分享到:

使用道具 举报

发表于 2006-10-26 10:30 | 显示全部楼层
你所调用的函数是有输出的,但是该输出在函数内部没定义。

官方的解释如下:
Explanation:
One of the functions you have called is defined to return an output argument but that output argument does not exist in that function when it tries to return.

Common causes:
You have misspelled the name of one of your output arguments inside your function, or you have forgotten to assign a value to one of the output arguments of your function. Alternatively, the function was originally written with one or more output arguments, but the section of the function that computed the output argument was removed or modified in such a way that the output argument is now extraneous.

Solution:
Stop MATLAB on the last line of the function listed in the warning or error message. Verify that each of the output arguments listed in the function declaration line at the beginning of the function exists after that last line is executed (using the DBSTEP function or the Step button in the Editor). If the arguments do not, examine the function to determine where you intended the arguments to be declared. Verify that those lines of code are being executed and have no typographical errors.

Example demonstrating this error:
OutputNotAssigned.m

评分

1

查看全部评分

发表于 2006-10-26 10:34 | 显示全部楼层
原帖由 sdzx112233 于 2006-10-26 10:27 发表
各位大虾 ,偶碰到这个问题n久也没弄明白怎么回事,请各位指点一下

哦,对了,补充一下,程序里所有的输出变量的值都能算出来,然后最后出现这个报错的



贴一下程序吧,估计你有一个以上的输出变量没有赋值,也许是使用了条件判断导致的
 楼主| 发表于 2006-10-26 10:47 | 显示全部楼层
谢谢happy的指点,茅塞顿开阿,呵呵
也谢谢eight的热心帮助拉
 楼主| 发表于 2006-10-26 10:48 | 显示全部楼层
小弟在function CeqHE=Heater(HEObj)
和CeqPA = [CeqF(:)' CeqM(:)' CeqE(:)' CeqSx CeqSy CeqH CeqSum1 CeqSum1];
上两个变量名不一致造成的,哈,低级错误,不要见笑哈
 楼主| 发表于 2006-10-26 11:17 | 显示全部楼层
另外还有个问题想请大虾们帮忙了,能教我如何写这个方程吗?我是初学的,好多还不懂……

E{ X(i) [ K(i) - 1) ] / [( K(i) - 1 ) r-1 ]}=0

E做加和的那个c戈马用,那个符号不会打……
X和K都是数组
方程用来求 r
发表于 2006-10-26 11:22 | 显示全部楼层
原帖由 sdzx112233 于 2006-10-26 11:17 发表
另外还有个问题想请大虾们帮忙了,能教我如何写这个方程吗?我是初学的,好多还不懂……

E{ X(i)  / }=0

E做加和的那个c戈马用,那个符号不会打……
X和K都是数组
方程用来求 r


把方程描述的清楚点,这样还是没太看明白
 楼主| 发表于 2006-10-26 11:25 | 显示全部楼层
方程式       X(i)* [ K(i) - 1) ]
          E  ------------------------ = 0
                   [ K(i) - 1 ]* r - 1


E做加和的那个c戈马用,那个符号不会打……
X和K都是数组
方程用来求 r
r是一个数

[ 本帖最后由 sdzx112233 于 2006-10-26 11:27 编辑 ]
发表于 2006-10-26 11:27 | 显示全部楼层
是对i求c戈马吧?
 楼主| 发表于 2006-10-26 11:29 | 显示全部楼层
是的,加和等于0
发表于 2006-10-26 11:32 | 显示全部楼层
原帖由 sdzx112233 于 2006-10-26 11:29 发表
是的,加和等于0


和普通的方程求解没什么区别,用矩阵运算或者循环把方程表示出来然后求解就行了
看你用哪个熟练吧,建议用矩阵运算,效率比较高
 楼主| 发表于 2006-10-26 11:40 | 显示全部楼层
只是分母上的[ K(i) - 1 ]* r 怎么处理?好像没办法做循环吧……
另外这个能用矩阵来算吗?没头绪……呵呵
能不能写段程序让我参考一下,呵呵,不胜感激!~
发表于 2006-10-26 17:49 | 显示全部楼层
syms r
x0=solve(sum(x.*(k-1)./((k-1)*r-1)));

评分

1

查看全部评分

 楼主| 发表于 2006-10-27 10:22 | 显示全部楼层
谢谢happy

[ 本帖最后由 sdzx112233 于 2006-10-28 12:20 编辑 ]
发表于 2008-3-26 20:47 | 显示全部楼层
真是太对了 我也有这个问题 刚刚解决 谢了 很对啊
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-18 08:22 , Processed in 0.067394 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表