Effacer les filtres
Effacer les filtres

Info

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

How to delete the columns of a cell array if the last elements of the columns are zero

1 vue (au cours des 30 derniers jours)
H R
H R le 2 Mar 2019
Clôturé : MATLAB Answer Bot le 20 Août 2021
Hi All,
I have a large cell arry PP with three rows and lots of columns as follows:
'A.txt' 'A2.bmp' 'A5.jpg'
1.1 1.3 1.4
1 1 0
How to delete the columns whose last elements are zero. After deleting the columns PP should look like this
'A.txt' 'A2.bmp'
1.1 1.3
1 1
Thanks.

Réponses (1)

Luna
Luna le 2 Mar 2019
Hi,
You can use this:
myArray = {'A','B','C','D'; 2 2 4 0;1 1 5 2; 1 1 6 0; 1 1 0 1};
newArray = myArray(:,~([myArray{end,:}] == 0))

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by