inputs:
1. array to be padded (double only)
2. length to be achieved after padding (double only)
3. value of the pad (eg: use 0 if zero padding is required) (double only)
4. where to pad? options (a) pre (attach padding before the array) (b) post (attach padding after the array) (c) both (attach padding before and after *) (string only)
output: padded array (double)
process:
many times we have arrays of different length but need to pad them in such a way that the final length of all the arrays are the same. So we need an adaptive function here that adapts to the current length, calculated the padding elements required to make it to the final length. The function here does the same but it is more robust. User can choose to add the padding either before or after the array.
* - but in CNN projects, user may need to add padding on both sides of the image (above and below not considered here). So the user can iterate through the image rows and use this function to add EVEN padding on both sides. If the user enters the final length such that the number of padding elements required (to achieve the the final length) are ODD number of elements, it throws error (because the function cannot know where to place more elements than the other).
Cite As
Anmol Pardeshi (2024). trailPadding (https://www.mathworks.com/matlabcentral/fileexchange/77969-trailpadding), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxTags
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 |
|