Hello Ankanna,
To achieve the desired workflow, follow these steps:
- Start by generating all the paths.
n = 3; L = 3;
allPaths = dec2bin(0:2^L-1) - '0';
expr = cell(size(allPaths,1), 1);
- Find the relevant expression for each path.
for i = 1:size(allPaths,1)
adj = zeros(n);
% If link 1-2 exists
if allPaths(i,1)==1
adj(1,2) = 1; adj(2,1) = 1;
end
% If link 1-3 exists
if allPaths(i,2)==1
adj(1,3) = 1; adj(3,1) = 1;
end
% If link 2-3 exists
if allPaths(i,3)==1
adj(2,3) = 1; adj(3,2) = 1;
end
if adj(1,3)
expr{i} = 'r1r3';
elseif adj(1,2) && adj(2,3)
expr{i} = 'r1r2r3';
else
expr{i} = '0.00';
end
end
- Store the data in Table format.
T = table(allPaths(:,1), allPaths(:,2), allPaths(:,3), expr, ...
'VariableNames', {'12', '13', '23', 'path'})