Filter löschen
Filter löschen

Resizing of cells in a cell array

4 Ansichten (letzte 30 Tage)
Doina Gumeniuc
Doina Gumeniuc am 5 Dez. 2017
Beantwortet: KL am 5 Dez. 2017
Hi all,
I have 84x50 cells array and each cell has a different length (1 row and many columns). I would like to resize it so if length>3, I would like to delete the rest of the values from the row. If length <3 then I would like to add zeros (this I know how to do). In the end, I would each of my cell to has a length of 3 (1 row and 3 columns). Could you please give me a hint on how to show that? Specially with deleting the remaining values.
Thank you!

Akzeptierte Antwort

KL
KL am 5 Dez. 2017
Use a loop,
for k=1:numel(C)
if numel(C(k))<3
C(k) = [C(k) zeros(1,3-numel(C(k)));
else
C(k) = C(1:3)
end
end

Weitere Antworten (0)

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by