Skip to content

Commit 24de2fd

Browse files
authored
Initial README update
1 parent 832c14b commit 24de2fd

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

README.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,109 @@
11
# MATLAB_samesize
22
Takes any number of cell or double arrays and resizes them all to the same dimensions. Also serves to resize any array with removal of extra rows/columns and adding of NaN, 0, or empty string rows/columns.
3+
4+
## Table of Contents
5+
* [Overview](#overview)
6+
* [Arguments](#arguments)
7+
* [Examples](#examples)
8+
* [Notes and Warnings](#notes-and-warnings)
9+
10+
## Overview
11+
Matrices can be truncated to match the smallest dimensions of the
12+
matrices, or extended with a filler value to match the largest dimensions
13+
of the matrices. For this behavior, the program will find the
14+
minimum and maximum number of rows and columns from all the inputted
15+
arrays and use those to set the dimensions of all arrays depending on
16+
whether "small" or "big" was selected in the options. Default is "big".
17+
18+
Matrices can also be resized to certain inputted dimensions, in which case too large dimesions will be truncated and too small will be filled.
19+
The matrix filler defaults to NaN but can also be set to zero or an empty string.
20+
One output matrix is given for every input matrix.
21+
You can even mix inputs of double arrays and cell arrays and each array will be passed back in the same form it entered.
22+
See arguments notes below.
23+
24+
## Arguments
25+
26+
* varargin: Any number of arrays of either class double or cell can be passed in. They can be of any size. One output is created for each input array.
27+
28+
```MATLAB
29+
samesize(array1,array2,array3,array4,...)
30+
```
31+
32+
### Name-Value Pair Arguments:
33+
34+
* RowCol: Manually sets the desired size of the output matrices. Must be submitted as a 1x2 non-zero integer vector indicating [rowsize, columnsize].
35+
36+
* SmallBig: Sets whether to truncate larger matrices to the size of the smallest dimesions of any matrix, or extend smaller matrices to the size of the largest. Must be either "small" or "big". Defaults to "big". If the rows and columns have been manually set, this input is ignored.
37+
38+
* Filler: Sets whether to fill extra rows and columns with NaN, zero, or an empty string (only for cell arrays). Must be "NaN", "nan", "zero", "0", "String", or "string". Defaults to "NaN".
39+
40+
### Outputs:
41+
42+
varargout: Ouputs one array for each array in the input. They can be accessed in the order they were entered. You do not necessarily have to take every output that is generated.
43+
44+
Example:
45+
```MATLAB
46+
[a,b] = samesize(a,b,c,d)
47+
```
48+
will return output for a and b but not c and d. However, if you want just c and d, the call must look like
49+
```MATLAB
50+
[~,~,c,d] = samesize(a,b,c,d)
51+
```
52+
53+
## Examples
54+
55+
Example function call with minimum arguments:
56+
57+
```MATLAB
58+
samesize(a,b) %(where a and b are arrays of class cell or double)
59+
```
60+
61+
In this case, default behavior will resize a and b to the largest dimensions of the arrays.
62+
63+
With output:
64+
65+
```MATLAB
66+
[a,b] = samesize(a,b)
67+
```
68+
69+
With optional arguments for manual dimensions:
70+
71+
```MATLAB
72+
[a,b] = samesize(a,b,"RowCol", [3,4])
73+
```
74+
75+
With optional argument for shrinking to smallest or expanding to biggest:
76+
77+
```MATLAB
78+
[a,b] = samesize(a,b,"SmallBig", "small")
79+
```
80+
81+
With optional argument for filler type:
82+
83+
```MATLAB
84+
[a,b] = samesize(a,b,"Filler","zero")
85+
```
86+
87+
## Notes and Warnings
88+
89+
### A note on behavior:
90+
91+
As mentioned above, the default response of the program is to make all
92+
arrays the size of the largest dimensions of the arrays given. For
93+
example, if you submit a 1x3 matrix and a 3x1 matrix, the result will be
94+
3x3 matrices with 2 rows of NaN for the first matrix and two columns of
95+
NaN for the second, as this is the largest combination of rows and
96+
columns of the matrices given. Likewise, if you submit a 3x3 matrix and
97+
a 1x3 matrix, the result will be 3x3 matrices with no changes to the
98+
first matrix and two rows of NaN for the second.
99+
100+
This same behavior applies to the "small"
101+
option. (i.e. an input of a 2x3 matrix and a 3x2 matrix with "small"
102+
selected will output 2x2 matrices with the extra column of the first
103+
matrix and the extra row of the second removed.)
104+
105+
For manually set dimensions, all matrices will have rows/columns added or subtracted as necessary to make them the correct size.
106+
107+
### Warning:
108+
109+
I am not a professional developer or programmer. If there are unforseen issues or bugs please let me know, but no promises on the reliability of this function. I've done my best to think of all possible situations but it's likely I missed something. Thanks!

0 commit comments

Comments
 (0)