请教matlab问题,输出参数问题
我编了一个程序,运行时出现下面的问题:One or more output arguments not assigned during call to 'birth4'.我检查了半天没有找到解决办法,请高手指点!谢谢function =birth4(sm,svar,s,b,d,y,m,laplace0)
k=4; %k=3 before this step
%there are two types
if sm(3,2)~=0&sm(3,6)~=0
w=unifrnd(0,1);
if w>=0&w<=1/3 %determine which is the splitting node based on w
sm(4,1)=1;sm(4,3)=1;s(4,1)=8;s(4,3)=9;
if svar(1,8)=='y1'&svar(2,4)=='y2'
svar(3,2)='y3';
z1=y(:,1);z2=y(:,2);z3=y(:,3);PP='z1=y1z2=y2z3=y3';
S=;Svar=;
elseif svar(1,8)=='y1'&svar(2,4)=='y3'
svar(3,2)='y2';
z1=y(:,1);z2=y(:,3);z3=y(:,2);PP='z1=y1z2=y3z3=y2';
S=;Svar=;
elseif svar(1,8)=='y2'&svar(2,4)=='y1'
svar(3,2)='y3';
z1=y(:,2);z2=y(:,1);z3=y(:,3);PP='z1=y2z2=y1z3=y3';
S=;Svar=;
elseif svar(1,8)=='y2'&svar(2,4)=='y3'
svar(3,2)='y1';
z1=y(:,2);z2=y(:,3);z3=y(:,1);PP='z1=y2z2=y3z3=y1';
S=;Svar=;
elseif svar(1,8)=='y3'&svar(2,4)=='y1'
svar(3,2)='y2';
z1=y(:,3);z2=y(:,1);z3=y(:,2);PP='z1=y3z2=y1z3=y2';
S=;Svar=;
elseif svar(1,8)=='y3'&svar(2,4)=='y2'
svar(3,2)='y1';
z1=y(:,3);z2=y(:,2);z3=y(:,1);PP='z1=y3z2=y2z3=y1';
S=;Svar=;
end
N=termsplit(sm);
=parsubsample(N,z1,z2,z3,m);
laplace=lap4(Y1,Y2,Y3,Y4,f,g,h,l,y,m,c);
DT=1;
accprob=laplace/laplace0*poisspdf(k,6)/poisspdf(k-1,6)*d(k)/b(k-1)*1/DT;
elseif w>1/3&w<=2/3
sm(4,5)=1;sm(4,7)=1;s(4,5)=10;s(4,7)=11;
if svar(1,8)=='y1'&svar(2,4)=='y2'
svar(3,6)='y3';
z1=y(:,1);z2=y(:,2);z3=y(:,3);PP='z1=y1z2=y2z3=y3';
S=;Svar=;
elseif svar(1,8)=='y1'&svar(2,4)=='y3'
svar(3,6)='y2';
z1=y(:,1);z2=y(:,3);z3=y(:,2);PP='z1=y1z2=y3z3=y2';
S=;Svar=;
elseif svar(1,8)=='y2'&svar(2,4)=='y1'
svar(3,6)='y3';
z1=y(:,2);z2=y(:,1);z3=y(:,3);PP='z1=y2z2=y1z3=y3';
S=;Svar=;
elseif svar(1,8)=='y2'&svar(2,4)=='y3'
svar(3,6)='y1';
z1=y(:,2);z2=y(:,3);z3=y(:,1);PP='z1=y2z2=y3z3=y1';
S=;Svar=;
elseif svar(1,8)=='y3'&svar(2,4)=='y1'
svar(3,6)='y2';
z1=y(:,3);z2=y(:,1);z3=y(:,2);PP='z1=y3z2=y1z3=y2';
S=;Svar=;
elseif svar(1,8)=='y3'&svar(2,4)=='y2'
svar(3,6)='y1';
z1=y(:,3);z2=y(:,2);z3=y(:,1);PP='z1=y3z2=y2z3=y1';
S=;Svar=;
end
N=termsplit(sm);
=parsubsample(N,z1,z2,z3,m);
laplace=lap4(Y1,Y2,Y3,Y4,f,g,h,l,y,m,c);
DT=1;
accprob=laplace/laplace0*poisspdf(k,6)/poisspdf(k-1,6)*d(k)/b(k-1)*1/DT;
elseif w>2/3&w<=1
sm(3,10)=1;sm(3,14)=1;s(3,10)=6;s(3,14)=7;
if svar(1,8)=='y1'&svar(2,4)=='y2'
v=unifrnd(0,1);
if v>=0&v<=0.5
svar(2,12)='y2';
z1=y(:,1);z2=y(:,2);z3=y(:,3);PP='z1=y1z2=y2z3=y3/z1=y1z2=y2z3=y3';
S=;Svar=;
N=termsplit(sm);
=parsubsample(N,z1,z2,z3,m);
else
svar(2,12)='y3';
z1=y(:,1);z2=y(:,2);z3=y(:,3);PP='z1=y1z2=y2z3=y3/z1=y1z2=y3z3=y2';
S=;Svar=;
N=termsplit(sm);
=parsubsample2(N,z1,z2,z3,m);
end
elseif svar(1,8)=='y1'&svar(2,4)=='y3'
v=unifrnd(0,1);
if v>=0&v<=0.5
svar(2,12)='y3';
z1=y(:,1);z2=y(:,3);z3=y(:,2);PP='z1=y1z2=y3z3=y2/z1=y1z2=y3z3=y2';
S=;Svar=;
N=termsplit(sm);
=parsubsample(N,z1,z2,z3,m);
else
svar(2,12)='y2';
z1=y(:,1);z2=y(:,3);z3=y(:,2);PP='z1=y1z2=y3z3=y2/z1=y1z2=y2z3=y3';
S=;Svar=;
N=termsplit(sm);
=parsubsample2(N,z1,z2,z3,m);
end
elseif svar(1,8)=='y2'&svar(2,4)=='y1'
v=unifrnd(0,1);
if v>=0&v<=0.5
svar(2,12)='y1';
z1=y(:,2);z2=y(:,1);z3=y(:,3);PP='z1=y2z2=y1z3=y3/z1=y2z2=y1z3=y3';
S=;Svar=;
N=termsplit(sm);
=parsubsample(N,z1,z2,z3,m);
else
svar(2,12)='y3';
z1=y(:,2);z2=y(:,1);z3=y(:,3);PP='z1=y2z2=y1z3=y3/z1=y2z2=y3z3=y1';
S=;Svar=;
N=termsplit(sm);
=parsubsample2(N,z1,z2,z3,m);
end
elseif svar(1,8)=='y2'&svar(2,4)=='y3'
v=unifrnd(0,1);
if v>=0&v<=0.5
svar(2,12)='y3';
z1=y(:,2);z2=y(:,3);z3=y(:,1);PP='z1=y2z2=y3z3=y1/z1=y2z2=y3z3=y1';
S=;Svar=;
N=termsplit(sm);
=parsubsample(N,z1,z2,z3,m);
else
svar(2,12)='y1';
z1=y(:,2);z2=y(:,3);z3=y(:,1);PP='z1=y2z2=y3z3=y1/z1=y2z2=y1z3=y3';
S=;Svar=;
N=termsplit(sm);
=parsubsample2(N,z1,z2,z3,m);
end
elseif svar(1,8)=='y3'&svar(2,4)=='y1'
v=unifrnd(0,1);
if v>=0&v<=0.5
svar(2,12)='y1';
z1=y(:,3);z2=y(:,1);z3=y(:,2);PP='z1=y3z2=y1z3=y2/z1=y3z2=y1z3=y2';
S=;Svar=;
N=termsplit(sm);
=parsubsample(N,z1,z2,z3,m);
else
svar(2,12)='y2';
z1=y(:,3);z2=y(:,1);z3=y(:,2);PP='z1=y3z2=y1z3=y2/z1=y3z2=y2z3=y1';
S=;Svar=;
N=termsplit(sm);
=parsubsample2(N,z1,z2,z3,m);
end
elseif svar(1,8)=='y3'&svar(2,4)=='y2'
v=unifrnd(0,1);
if v>=0&v<=0.5
svar(2,12)='y2';
z1=y(:,3);z2=y(:,2);z3=y(:,1);PP='z1=y3z2=y2z3=y1/z1=y3z2=y2z3=y1';
S=;Svar=;
N=termsplit(sm);
=parsubsample(N,z1,z2,z3,m);
else
svar(2,12)='y1';
z1=y(:,3);z2=y(:,2);z3=y(:,1);PP='z1=y3z2=y2z3=y1/z1=y3z2=y1z3=y2';
S=;Svar=;
N=termsplit(sm);
=parsubsample2(N,z1,z2,z3,m);
end
end
laplace=lap4(Y1,Y2,Y3,Y4,f,g,h,l,y,m,c);
DT=2;
ccprob=laplace/laplace0*poisspdf(k,6)/poisspdf(k-1,6)*d(k)/b(k-1)*1/DT;
end
elseif sm(3,10)~=0&sm(3,14)~=0
w=unifrnd(0,1);
if w>=0&w<=1/3 %determine which is the splitting node based on w
sm(4,13)=1;sm(4,15)=1;s(4,13)=14;s(4,15)=15;
if svar(1,8)=='y1'&svar(2,12)=='y2'
svar(3,14)='y3';
z1=y(:,1);z2=y(:,2);z3=y(:,3);PP='z1=y1z2=y2z3=y3';
S=;Svar=;
elseif svar(1,8)=='y1'&svar(2,12)=='y3'
svar(3,14)='y2';
z1=y(:,1);z2=y(:,3);z3=y(:,2);PP='z1=y1z2=y3z3=y2';
S=;Svar=;
elseif svar(1,8)=='y2'&svar(2,12)=='y1'
svar(3,14)='y3';
z1=y(:,2);z2=y(:,1);z3=y(:,3);PP='z1=y2z2=y1z3=y3';
S=;Svar=;
elseif svar(1,8)=='y2'&svar(2,12)=='y3'
svar(3,14)='y1';
z1=y(:,2);z2=y(:,3);z3=y(:,1);PP='z1=y2z2=y3z3=y1';
S=;Svar=;
elseif svar(1,8)=='y3'&svar(2,12)=='y1'
svar(3,14)='y2';
z1=y(:,3);z2=y(:,1);z3=y(:,2);PP='z1=y3z2=y1z3=y2';
S=;Svar=;
elseif svar(1,8)=='y3'&svar(2,12)=='y2'
svar(3,14)='y1';
z1=y(:,3);z2=y(:,2);z3=y(:,1);PP='z1=y3z2=y2z3=y1';
S=;Svar=;
end
N=termsplit(sm);
=parsubsample(N,z1,z2,z3,m);
laplace=lap4(Y1,Y2,Y3,Y4,f,g,h,l,y,m,c);
DT=1;
accprob=laplace/laplace0*poisspdf(k,6)/poisspdf(k-1,6)*d(k)/b(k-1)*1/DT;
elseif w>1/3&w<=2/3
sm(4,9)=1;sm(4,11)=1;s(4,9)=12;s(4,11)=13;
if svar(1,8)=='y1'&svar(2,12)=='y2'
svar(3,10)='y3';
z1=y(:,1);z2=y(:,2);z3=y(:,3);PP='z1=y1z2=y2z3=y3';
S=;Svar=;
elseif svar(1,8)=='y1'&svar(2,12)=='y3'
svar(3,10)='y2';
z1=y(:,1);z2=y(:,3);z3=y(:,2);PP='z1=y1z2=y3z3=y2';
S=;Svar=;
elseif svar(1,8)=='y2'&svar(2,12)=='y1'
svar(3,10)='y3';
z1=y(:,2);z2=y(:,1);z3=y(:,3);PP='z1=y2z2=y1z3=y3';
S=;Svar=;
elseif svar(1,8)=='y2'&svar(2,12)=='y3'
svar(3,10)='y1';
z1=y(:,2);z2=y(:,3);z3=y(:,1);PP='z1=y2z2=y3z3=y1';
S=;Svar=;
svar(3,10)='y2';
z1=y(:,3);z2=y(:,1);z3=y(:,2);PP='z1=y3z2=y1z3=y2';
S=;Svar=;
elseif svar(1,8)=='y3'&svar(2,12)=='y2'
svar(3,10)='y1';
z1=y(:,3);z2=y(:,2);z3=y(:,1);PP='z1=y3z2=y2z3=y1';
S=;Svar=;
end
N=termsplit(sm);
=parsubsample(N,z1,z2,z3,m);
laplace=lap4(Y1,Y2,Y3,Y4,f,g,h,l,y,m,c);
DT=1;
accprob=laplace/laplace0*poisspdf(k,6)/poisspdf(k-1,6)*d(k)/b(k-1)*1/DT;
elseif w>2/3&w<=1
sm(3,2)=1;sm(3,6)=1;s(3,2)=4;s(3,6)=5;
if svar(1,8)=='y1'&svar(2,12)=='y2'
v=unifrnd(0,1);
if v>=0&v<=0.5
svar(2,4)='y2';
z1=y(:,1);z2=y(:,2);z3=y(:,3);PP='z1=y1z2=y2z3=y3/z1=y1z2=y2z3=y3';
S=;Svar=;
N=termsplit(sm);
=parsubsample(N,z1,z2,z3,m);
else
svar(2,4)='y3';
z1=y(:,1);z2=y(:,2);z3=y(:,3);PP='z1=y1z2=y3z3=y2/z1=y1z2=y2z3=y3';
S=;Svar=;
N=termsplit(sm);
=parsubsample1(N,z1,z2,z3,m);
end
elseif svar(1,8)=='y1'&svar(2,12)=='y3'
v=unifrnd(0,1);
if v>=0&v<=0.5
svar(2,4)='y3';
z1=y(:,1);z2=y(:,3);z3=y(:,2);PP='z1=y1z2=y3z3=y2/z1=y1z2=y3z3=y2';
S=;Svar=;
N=termsplit(sm);
=parsubsample(N,z1,z2,z3,m);
else
svar(2,4)='y2';
z1=y(:,1);z2=y(:,3);z3=y(:,2);PP='z1=y1z2=y2z3=y3/z1=y1z2=y3z3=y2';
S=;Svar=;
N=termsplit(sm);
=parsubsample1(N,z1,z2,z3,m);
end
elseif svar(1,8)=='y2'&svar(2,12)=='y1'
v=unifrnd(0,1);
if v>=0&v<=0.5
svar(2,4)='y1';
z1=y(:,2);z2=y(:,1);z3=y(:,3);PP='z1=y2z2=y1z3=y3/z1=y2z2=y1z3=y3';
S=;Svar=;
N=termsplit(sm);
=parsubsample(N,z1,z2,z3,m);
else
svar(2,4)='y3';
z1=y(:,2);z2=y(:,1);z3=y(:,3);PP='z1=y2z2=y3z3=y1/z1=y2z2=y1z3=y3';
S=;Svar=;
N=termsplit(sm);
=parsubsample1(N,z1,z2,z3,m);
end
elseif svar(1,8)=='y2'&svar(2,12)=='y3'
v=unifrnd(0,1);
if v>=0&v<=0.5
svar(2,14)='y3';
z1=y(:,2);z2=y(:,3);z3=y(:,1);PP='z1=y2z2=y3z3=y1/z1=y2z2=y3z3=y1';
S=;Svar=;
N=termsplit(sm);
=parsubsample(N,z1,z2,z3,m);
else
svar(2,4)='y1';
z1=y(:,2);z2=y(:,3);z3=y(:,1);PP='z1=y2z2=y1z3=y3/z1=y2z2=y3z3=y1';
S=;Svar=;
N=termsplit(sm);
=parsubsample1(N,z1,z2,z3,m);
end
elseif svar(1,8)=='y3'&svar(2,12)=='y1'
v=unifrnd(0,1);
if v>=0&v<=0.5
svar(2,4)='y1';
z1=y(:,3);z2=y(:,1);z3=y(:,2);PP='z1=y3z2=y1z3=y2/z1=y3z2=y1z3=y2';
S=;Svar=;
N=termsplit(sm);
=parsubsample(N,z1,z2,z3,m);
else
svar(2,4)='y2';
z1=y(:,3);z2=y(:,1);z3=y(:,2);PP='z1=y3z2=y2z3=y1/z1=y3z2=y1z3=y2';
S=;Svar=;
N=termsplit(sm);
=parsubsample1(N,z1,z2,z3,m);
end
elseif svar(1,8)=='y3'&svar(2,12)=='y2'
v=unifrnd(0,1);
if v>=0&v<=0.5
svar(2,4)='y2';
z1=y(:,3);z2=y(:,2);z3=y(:,1);PP='z1=y3z2=y2z3=y1/z1=y3z2=y2z3=y1';
S=;Svar=;
N=termsplit(sm);
=parsubsample(N,z1,z2,z3,m);
else
svar(2,4)='y1';
z1=y(:,3);z2=y(:,2);z3=y(:,1);PP='z1=y3z2=y1z3=y2/z1=y3z2=y2z3=y1';
S=;Svar=;
N=termsplit(sm);
=parsubsample1(N,z1,z2,z3,m);
end
end
laplace=lap4(Y1,Y2,Y3,Y4,f,g,h,l,y,m,c);
DT=2;
accprob=laplace/laplace0*poisspdf(k,6)/poisspdf(k-1,6)*d(k)/b(k-1)*1/DT;
end
end
本文来自: 人大经济论坛(http://www.pinggu.org) 详细出处参考:http://www.pinggu.org/bbs/dispbbs.asp?boardid=71&id=375747
[ 本帖最后由 sigma665 于 2008-10-24 17:56 编辑 ]
还有一个matlab问题要请教
还有一个程序,调用的时候也出现出现下面的错误 One or more output arguments not assigned during call to 'parsubsample'?请求高手指点!谢谢function =parsubsample(N,z1,z2,z3,m)
m=length(z1);
c(1)=0;
if N(1,8)=='terminal'
P=sym('[ ]');
f=0;g=0;h=0;l=0;o=0;p=0;q=0;r=0;
for t=2:m
f=f+1;
Y1(f,:)=;
c(t)=1;
end
Y2=zeros(0,3);Y3=zeros(0,3);Y4=zeros(0,3);Y5=zeros(0,3);
Y6=zeros(0,3);Y7=zeros(0,3);Y8=zeros(0,3);
end One or more output arguments not assigned during call to 'parsubsample'
调用函数parsubsample时,输出函数变量没有定义或者输出函数超出了定义时输出函数数。
回复 楼主 xiuxiamath 的帖子
"output arguments not assigned"不是告诉你的?输出引数有些没回传, 可能没定义
估计if或for根本没执行
回复 楼主 xiuxiamath 的帖子
同另一问题输出引数有些没回传, 可能没定义
估计if或for根本没执行 哦,谢谢!我又实验了一次,把parsubsample中的相关内容直接拷到调用该函数的函数文件中,稍微做了一点修改,程序如下:
直接调用下列函数death1时for循环运行不出来,也就是Y1生成不了,但是把下列函数的内容粘贴到命令窗口中就可以运行,请问这是什么原因?怎么解决呢?
function =death1(sm,svar,s,y,b,d,m,laplace0)
k=1; %k=2 before this death step
sm(2,4)=0;sm(2,12)=0;s(2,4)=0;s(2,12)=0;svar(1,8)=sym('[]');
z1=y(:,1);z2=y(:,2);z3=y(:,3);PP='z1=y1z2=y2z3=y3';
S=zeros(0,0);Svar=zeros(0,0);
N=termsplit(sm);
%the parsubsample function
m=length(z1);
%m is the number of elements in z1, z2 and z3
c(1)=0;
%to find the corresponding partion of the tree and the corresponding
%subsamples when svar(1,8)=z1,svar(2,4)=svar(2,,12)=z2,svar(3,2)=svar(3,6)=svar(3,10)=svar(3,14)=z3
%if the root node is the terminal node
P=sym('[]');
f=0;g=0;h=0;l=0;o=0;p=0;q=0;
for t=2:m
f=f+1;
Y1(f,:)=;
c(t)=1;
end
Y2=zeros(0,3);Y3=zeros(0,3);Y4=zeros(0,3);Y5=zeros(0,3);Y6=zeros(0,3);Y7=zeros(0,3);Y8=zeros(0,3);
%end of parsubsample function
laplace=lap1(Y1,f,y,m,c);
DT=1;
accprob=laplace/laplace0*poisspdf(k,6)/poisspdf(k+1,6)*b(k)/d(k+1)*DT;
页:
[1]