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
0 件のコメント
採用された回答
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 Center および File Exchange で Database Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!