Zigzag matrix selection

Traverses an mxn matrix in a zigzag order and keeps the first k elements. Others are set to zero.
38 Downloads
Updated 5 Feb 2017

View License

Written as part of DCT coefficient selection procedure for image compression. Might have other uses.
zigzag([1 2 6 7; 3 5 8 11; 4 9 10 12], 10)

ans =

1 2 6 7
3 5 8 0
4 9 10 0

Cite As

Tyler Stephen (2025). Zigzag matrix selection (https://www.mathworks.com/matlabcentral/fileexchange/61453-zigzag-matrix-selection), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2016b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.0.0.0