How to store all the results in a cell?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
M
el 22 de Jul. de 2023
Comentada: M
el 22 de Jul. de 2023
Suppose there is a cell "d" and its size 6*6
and I want to perfom a calculation on it and store all the results in "d11"
I tried the following but I got only the last index but I want all the results.
What I have to modify?
d11 = cell(6,6);
d = num2cell(rand(6));
for i = 6
for j= 6
d1 = [d{i,j};zeros(1,size(d{i,j},2))];
d11{i,j} = d1
end
end
0 comentarios
Respuesta aceptada
Image Analyst
el 22 de Jul. de 2023
You didn't say what you expect, and the code is so wrong in so many ways that I can't figure out what you want. So I made this attempt.
d11 = cell(6,6);
d = num2cell(rand(6))
[rows, columns] = size(d11);
for col = 1 : columns
for row = 1 : rows
thisCellContents = [d{row, col}; zeros(rows, 1)];
d11{row, col} = thisCellContents;
end
end
celldisp(d11)
Is it what you want?
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrix Indexing 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!