Local Function not being Entered

7 次查看(过去 30 天)
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

采纳的回答

Steven Lord
Steven Lord 2020-11-19
You define the local function RPM1 in your script file, but you never call RMP1 inside your script file. MATLAB does not automatically call the local function for you.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Database Toolbox 的更多信息

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by