Preallocate a variable of unknown size
Show older comments
Please help to preallocate the variable "D". Its size is unknown.
clc;
D = {};
Di = [];
r = 1;
N = length(nodes.PrtCtyAll);
DstBlocks = cell(N,1);
for i = 1:N % Iterate through PrtCtyAll
for j = 1 : length(nodes.PrtCtyAll{i})
DstBlocks{i}{j,1} = nodes.PrtCtyAll{i}(j).DstBlock;
end
for k = 1 : length(DstBlocks{i})
if (~isempty(DstBlocks{i}{k}) && length(DstBlocks{i}{k})==1)
D{end+1,1} = DstBlocks{i}{k};
r = r + 1;
else
for z = 1:length(DstBlocks{i}{k})
D{end+1,1} = DstBlocks{i}{k}(z);
end
end
end
% Get Indices
for a = 1:length(D)
Di(a) = find(abs(nodes.Handles-D{a}) < 0.1);
end
Si = find(abs(nodes.Handles-nodes.Handles(i)) < 0.1);
Di = [];
D = {};
end
clear i j k r z a N D Di Si
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!