Cell array not fully defined on some execution paths error
1 回表示 (過去 30 日間)
古いコメントを表示
I'm trying to assign memory to all cells for the purpose of code conversion and getting an error "Variable 'x{1, n}' is not fully defined on some execution paths. " How do I fix this? %n=14
function z = mycell(n)
%#codegen
assert(n < 1);
x = cell(1,n);
for i = 1:n
x{i} = i;
end
z = x{n};
end
0 件のコメント
回答 (1 件)
Walter Roberson
2018 年 6 月 24 日
assert(n < 1);
that creates an error unless n is 0 or negative, in which case cell(1,n) will always be the empty cell...
3 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!