How to eliminate column of the matrix?

2 Ansichten (letzte 30 Tage)
Karanvir singh Sohal
Karanvir singh Sohal am 16 Mär. 2021
Beantwortet: the cyclist am 16 Mär. 2021
Hello everyone!
I have generated some matrix of size say mxn. I want to eliminate the columns which have all values equal to "0".
For example:
A=[ 1 2 3 ... 2 0
2 3 5 ... 3 0
3 5 6 ... 3 0]
Desired output
A=[1 2 3 ... 2
2 3 5 ... 3
3 5 6 ... 3]

Akzeptierte Antwort

the cyclist
the cyclist am 16 Mär. 2021
A(:,all(A==0)) = []

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by