Data Normalization is a technique in statistical mathematics that converts the entire data into a specified range or scale or normalizes it using different methods such as by computing its z-score. There is no specific definition of normalization but, it has various meanings depending on the user’s needs.
In this article, we will discuss how to normalize data in MATLAB with various options available. It is assumed that the reader has knowledge of Normalization as explaining the same is out of this article’s scope. Let us now see how Normalization is done in MATLAB.
Data Normalization in MATLAB:
MATLAB provides the normalize() function to normalize data. By default, it normalizes the data by calculating the vector-wise z-score of the data with center 0 and standard deviation 1.
Syntax:
N = normalize(data)
Where data could be
- A vector
- A Matrix
- A Multidimensional array
- A table
Now let us understand the same with examples.
Let us normalize the data in a vector.
Example 1:
Matlab
vec = 1:7;
Nvec = normalize(vec);
|
Output:
When a matrix is passed to the normalize() function, it normalizes all of its elements column-wise.
Example 2:
Matlab
mat = magic(3);
Nvec = normalize(mat);
|
Output:
Normalizing a matrix along a specific dimension.
Example 3:
Matlab
mat = magic(3);
Nvec1 = normalize(mat,1)
Nvec2 = normalize(mat,1)
|
Output:
We can also normalize a vector by scaling it by its standard deviation.
Example 4:
Matlab
vec = 1:7;
Nvec = normalize(vec, 'scale' );
|
Output:
MATLAB also provides an option to scale data in a range of [0,1]. This can be done as follows:
Example 5:
Matlab
vec = 1:7;
Nvec = normalize(vec, 'range' );
|
Output:
Last Updated :
27 Oct, 2022
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...