Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Remove padding from an array
ResourceFunction["ArrayCrop"][array] removes rows or columns of zeros from the top, bottom, left or right of an array. | |
ResourceFunction["ArrayCrop"][array,pad] removes rows or columns of pad from the top, bottom, left or right of an array. |
Remove the zero padding around an array:
| In[1]:= |
| Out[1]= |
Remove the zero padding around a more complicated array:
| In[2]:= | ![]() |
| Out[2]= |
| In[3]:= |
| Out[3]= |
Create a symbolic array and pad it with zeros:
| In[4]:= |
| Out[4]= | ![]() |
Remove the zero padding:
| In[5]:= |
| Out[5]= |
Create an array padded by xs:
| In[6]:= |
| Out[6]= |
Remove the padding:
| In[7]:= |
| Out[7]= |
Create a symbolic rank-3 array and pad it with zeros:
| In[8]:= |
| Out[8]= |
Remove the padding:
| In[9]:= |
| Out[9]= | ![]() |
If everything is padding, nothing is removed:
| In[10]:= |
| Out[11]= |
This work is licensed under a Creative Commons Attribution 4.0 International License