How do I add a column of zeros to the end of a matrix inside a cell?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
lil brain
am 26 Feb. 2022
Kommentiert: lil brain
am 27 Feb. 2022
Hello,
I have the cell "basket_xyz" and I would like balls_xyz{:,10} to only be zeros for the entire column or for the same length as all other columns.
I have tried using:
baskets_xyz{:,10} = zeros(length(baskets_xyz{:,9}, 1)
But it doesnt work.
What am I doing wrong?
Thanks!
2 Kommentare
Stephen23
am 27 Feb. 2022
Is there a particular reason why you are inefficiently storing lots of scalar numeric in a cell array, thus making it more difficult to process that numeric data? Why not just use one simple, efficient, numeric array?
S = load('baskets_xyz.mat')
M = cell2mat(S.baskets_xyz)
M(:,end+1) = 0
Akzeptierte Antwort
Voss
am 26 Feb. 2022
Maybe this?
load('baskets_xyz.mat')
baskets_xyz(:,10) = {0}
2 Kommentare
Voss
am 27 Feb. 2022
In this case, all the cells contained scalars, so putting a scalar 0 in all cells in the 10th column of the cell array made sense.
If you needed to put matrices of different sizes in the 10th column of another cell array and have the new matrices match sizes with what's already there, then you would need to do something different. This answer just puts the scalar 0's in place.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices 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!