Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

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

1 vue (au cours des 30 derniers jours)
Douglas Anderson
Douglas Anderson le 8 Déc 2018
Clôturé : MATLAB Answer Bot le 20 Août 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 commentaires
James Tursa
James Tursa le 8 Déc 2018
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?
Douglas Anderson
Douglas Anderson le 8 Déc 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!

Réponses (0)

Cette question est clôturée.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by