Effacer les filtres
Effacer les filtres

Cell array not fully defined on some execution paths error

1 vue (au cours des 30 derniers jours)
Zun Sid
Zun Sid le 24 Juin 2018
Commenté : Zun Sid le 25 Juin 2018
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

Réponses (1)

Walter Roberson
Walter Roberson le 24 Juin 2018
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 commentaires
Walter Roberson
Walter Roberson le 24 Juin 2018
assert(n >= 1)
Zun Sid
Zun Sid le 25 Juin 2018
ok thankyou

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB Coder dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by