How to remove column with 0 in matrix?

Illustration
Joshua Chhour - 2023-06-06T13:58:52+00:00
Question: How to remove column with 0 in matrix?

I have a 0x100x150 double, but how do I get rid of the zero, so it becomes 100x150?

Expert Answer

Profile picture of Neeta Dsouza Neeta Dsouza answered . 2025-11-20

You can use the squeeze() function in MATLAB to remove dimensions with size 1 in a multidimensional array.
The following code will give you, which is a 100x150 array but with same data as A.
 
% assuming your 0x100x150 double is named A
B = squeeze(A); % remove dimensions with size 1

 


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!