Local Function not being Entered
显示 更早的评论
I am trying to create a recursive algorithm, with a local function. But when i test the alg, the initial input variables don't seem to be entering the function. Any suggestions?
%Inputs
V = [4 4 4 4 4]; %vector of ports for a 5 node graph
E = []; %empty edge set
cVf = cumsum(V+1); %cumulative sum of vector plus 1
G = []%empty set of graphs
A = ones(5,5);
%plot(graph(G))
function RPM1(V, E, A, cVf, G)
iL = find(V, 1); %find first nonzero entry
L = cVf(iL)-V(iL); %left port
V(iL) = V(iL)-1; %remove the port
Vallow = V .* A(iL,:);
I = find(Vallow); %find non zero entries
for iR = I
R = cVf(iR) - V(iR) %right port
E2 = [E L R]; %combine left, right ports for an edge
V2 = V; %local remaing ports vector
V2(iR) = V2(iR) - 1; %remove port
A2 = A; %local expanded AM
if ~find(V2) %no remaining collections
G{end+1} = E2; %save missorted pm
else
G = [RPM1(V2,E2,A2,cVf,G)] %recursive
end
end
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!