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)
Afficher commentaires plus anciens
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
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?
Réponses (0)
Cette question est clôturée.
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!