How to delete 0 elements contained in a 3D array and store them in a new 3D array
2 views (last 30 days)
Show older comments
In the data stored in DividedW (3D array), in order to delete the 0 element, store the digital element in the ZERO array (3D array),I want to store the data with 0s removed in a new matrix DividedX (3D array). We are considering the program below, but as it isSince 0 is deleted, the array size is different for each Num, so an error occurs.I would appreciate it if you could teach me if there is any good way.
for Num = 1:(div1*div2)
ZERO(:,:,Num) = DividedW(:,:,Num) ~= 0;
RX(:,:,Num) = DividedX(ZERO(:,:,Num))
end
Also,
RX(:,:,Num) = DividedX(ZERO(:,:,Num))
↓
RX(:,:,Num) = DividedX(:,:,Num)(ZERO(:,:,Num))
I think that is the correct notation, but in this case () overlaps and an error is displayed.Is there any other notation method?
4 Comments
Rik
on 19 Jan 2021
That is not possible. Each page of a Matlab array must have the same number of rows and columns. If you want this, you could use a cell array. Whether that will solve your issue depends on what you want to do next.
Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!