Truncate file
Version 1.0.0 (1.91 KB) by
Dan Dolan
This function uses a Perl script to truncates a file to a specified number bytes without creating a second copy.
Have you ever needed to trim an existing file? MATLAB cannot do this natively without creating a new file, copying the bytes to be kept, and then deleting the original. This function uses a Perl script, which MATLAB can invoke from any* platform without compliation.
*I have not tested MATLAB Mobile.
Cite As
Dan Dolan (2025). Truncate file (https://www.mathworks.com/matlabcentral/fileexchange/182650-truncate-file), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2025b
Compatible with any release
Platform Compatibility
Windows macOS LinuxTags
Acknowledgements
Inspired by: FileResize
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0 |
