Info

# Resources/Suggestions for dealing with small slightly irregular arrays. Cell Array? (Edited)

1 view (last 30 days)
Douglas Anderson on 8 Dec 2018
Closed: MATLAB Answer Bot on 20 Aug 2021
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 CommentsShowHide 1 older comment
Douglas Anderson on 8 Dec 2018
James -- should have put this in a comment:
Hello James, and thank you.
Simply put, this is an "array" (in the loosest terms) of points on a grid that is almost rectangular. It starts out rectangular, and the user may delete some of them, making it non-rectangular. The points are independent (have data associated with them), except that the numbering of the points needs to be contiguous, like in the above example. Sometimes the numbering starts at the left, sometimes at the right, and sometimes in the middle (I've already figured that out for the full rectangle. I can use fliplr() or various colon combinations). It's just the oddball things with a couple of removed points that make the NUMBERING the big problem. I have a "kill_me()" function to delete the points.
Hope that helps. If you want to know more, let me know!