Why do get error in line 10: Function Keyword is invalid here. This might cause later messages about end.
Show older comments
I am trying to create a recursive function with output a Cell (1xN)that will consists of N matrixes. Each matrix represent a combination between the elements of X1 input Cell. I dont understand why i get this error.. Thank you for any help in advance!
VARMTD=[1,1/3,1/5];
VARMT1=(1:156);
ERLANGVARCELL={};
ERLANGVARCELL{1}=VARMT;
ERLANGVARCELL{2}=VARMTD;
A=zeros(1,length(ERLANGVARCELL));
ADR=zeros(1,length(ERLANGVARCELL));
Q=myfun(ERLANGVARCELL,A,ADR);
function G= myfun(x1,x4,ADR)
b=find(x4>0);
if length(b)==length(x1)
x3=length(b);
else
x3=length(b)+1;
end
i=ADR(x3)+1;
if i<=length(x1{x3})
x4(x3)=x1{x3}(i);
ADR(x3)=ADR(x3)+1;
end
for s=length(x1):1
hlp=1;
if s==length(x1);
hlp=1;
else
for b=(s+1):length(x1)
hlp=length(x1{b})*hlp;
end
end
if ADR(s)==length(x1{s})*hlp
ADR(s)=0;
x4(s-1)=0;
end
end
G=[x4,myfun(x1,x4,ADR)];
end
Accepted Answer
More Answers (0)
Categories
Find more on Data Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!