How to replace first and last element of each matrix in 7x1 cell with 0
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Tomaszzz
el 18 de Jul. de 2022
Comentada: Tomaszzz
el 18 de Jul. de 2022
Hi all,
I have a 7x 1 cell of 101x1 double.
I want to replace first and last element of each matrix with 0. Can you help please?
My approach:
for i = 1:length(cell)
cell{i}((cell(1:1)))=0;
cell{i}((cell(101:101)))=0;
end
Unable to use a value of type cell as an index.
0 comentarios
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 18 de Jul. de 2022
NewCell = cellfun(@(C) [0; C(2:end-1); 0], OldCell, 'uniform', 0);
Note: using cell as the name of a variable interfers with calling cell() to create a cell array... and confuses people reading your code.
Ver también
Categorías
Más información sobre Data Types 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!