필터 지우기
필터 지우기

Local Function not being Entered

조회 수: 2 (최근 30일)
Anthony Sirico
Anthony Sirico 2020년 11월 19일
댓글: Anthony Sirico 2020년 11월 19일
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