Cell contents reference from a non-cell array object, why?
Afficher commentaires plus anciens
Hello there, ellipse_l is a cell array and each element is also a cell array with a certain number of structs in it. Why do I get the error shown in the headline?
Greets!
X0_r = cell(length, 1);
for i = 1:(numel(find(~cellfun(@isempty, ellipse_l))))
for j = 1:(numel(find(~cellfun(@isempty, ellipse_l))))
X0_r{i}{j} = ellipse_r{i}{j}.X0;
end
end
Réponses (2)
James Tursa
le 30 Juil 2017
Modifié(e) : James Tursa
le 30 Juil 2017
As written, X0_r is a cell array, but the elements of this cell array are NULL (empty) since nothing has been put into it yet. So in this expression:
X0_r{i}{j}
you are trying to access the j'th element of a cell array, but there is no such cell array in that spot. That is, X0_r is a cell array but X0_r{i} is not a cell array since it is NULL (empty). So that {j} part attempts to access X0_r{i} as if it were a cell array which it isn't.
1 commentaire
Payjay
le 30 Juil 2017
Image Analyst
le 30 Juil 2017
length is is a built in function, so this doesn't make sense
X0_r = cell(length, 1);
Try this instead:
X0_r = cell(size(ellipse_l));
celldisp(ellipse_1); % Display it to verify it looks good.
celldisp(X0_r); % Display it to verify it's blank and the same size as ellipse_l.
Catégories
En savoir plus sur Operators and Elementary Operations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!