Info
此问题已关闭。 请重新打开它进行编辑或回答。
Resources/Suggestions for dealing with small slightly irregular arrays. Cell Array? (Edited)
2 次查看(过去 30 天)
显示 更早的评论
Hello,
I would like some suggestions on how to deal with (numbering, calculating, etc.) small arrays (such as 4 x 20) that will have elements deleted.
For instance, starting with
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
then user deleting some, how to deal with the elements of an array like
1 2 3 4 5 6 7
8 9 10 11 12 13
14 15 16 17 18
How do you renumber, and then want to have these numbers associated with other data? You can't mathematically manipulate a cell array like you can a standard array
% Script for slightly non-rectangular small array
num_holes = 7;
num_rows = 3;
total_holes = num_holes * num_rows;
x = 1:total_holes;
hole_array = reshape(x,num_holes,num_rows)'
flipped_hole_array = fliplr(hole_array)
flipped_cell_array = num2cell(flipped_hole_array)
flipped_cell_array{2,1} = [];
flipped_cell_array{3,1} = [];
flipped_cell_array{3,2} = [];
flipped_cell_array
Thanks.
2 个评论
James Tursa
2018-12-8
How will this be used downstream in your code? You can't have non-rectangular data in variables (full or sparse). Maybe you need to use a cell array. Is the data always going to be non-zero?
回答(0 个)
此问题已关闭。
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!