Cell contents reference from a non-cell array object, why?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuestas (2)
James Tursa
el 30 de Jul. de 2017
Editada: James Tursa
el 30 de Jul. de 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.
Image Analyst
el 30 de Jul. de 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.
0 comentarios
Ver también
Categorías
Más información sobre Structures en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!