EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials Matlab Tutorial MATLAB Normalize
 

MATLAB Normalize

Priya Pedamkar
Article byPriya Pedamkar

MATLAB Normalize

Introduction to MATLAB Normalize

MATLAB is a programming environment which is interactive and is used in scientific computing. It is extensively used in a lot of technical fields where problem solving, data analysis, algorithm development and experimentation is required. Software which are discipline specific are extensively written using MATLAB. MATLAB provides us with ‘normalize function’ for the purpose of performing normalization of vectors. We perform normalization if we need our data to be in a range something like [-1 to 1]. In other words, Normalization is linear transformation of our data and is necessary at times when limits are imposed on data because of floating point arithmetic.

 

 

Syntax:

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

A = normalize (X)

Description:

A = normalize (X) will return the z-score of data in X (standard deviation is 1 &center is 0).

In case the input ‘X’ is a vector, the normalize function will work on the entire input. If input ‘X’ is multidimensional array, the normalize function will operate along the 1st dimension of the array, whose size is not equal to 1.

Examples of MATLAB Normalize

Given below are the examples mentioned:

Example #1

Here we will see how the code for normalizing a 3 X 3 array looks like.

Code:

X = [3 4 6, 7 1 9, 0 2 2] [Creating the input 3 X 3 array]

A = normalize (X)

[Using the normalize function and passing the input array]

Input:

X = [3 4 6, 7 1 9, 0 2 2] A = normalize (X)

Output:

MATLAB Normalize 1

Example #2

Now what if all the elements of the array are same. Like in identity matrix, where all the elements are 1.

Input:

X = [1 1 1, 1 1 1, 1 1 1] A = normalize (X)

Output:

all the elements of the array are same

There are a few methods which we can pass as an argument to the normalize function in order to get the output as per our requirement.

Here are the 3 main methods which we can pass as the argument:

  • Scale: This method is used to normalize the input using standard deviation.
  • Range: This method normalizes the input in the range [0 to 1].
  • Center: This method will normalize the data to have ‘0’ as mean.

a. Scale

Code:

X = 1 : 7;

[Initializing the input vector]

A = normalize (X, ‘scale’)

[Calling the normalize function and passing the ‘scale’ method]

Input:

X = 1 : 7;
A = normalize (X, 'scale')

Output:

MATLAB Normalize 3

b. Range

Code:

X = 1 : 7;

[Initializing the input vector]

A = normalize (X, ‘range’)

[Calling the normalize function and passing the ‘range’ method]

Input:

X = 1 : 7;
A = normalize (X, 'range')

Output:

range

As we can see, our output is normalized in the range [0, 1].

3. Center

Code:

X = 1 : 7;

[Initializing the input vector]

A = normalize (X, ‘center’)

[Calling the normalize function and passing the ‘center’ method]

Input:

X = 1 : 7;
A = normalize (X, 'center')

Output:

center

As we can see, our output is normalized with ‘0’ as mean.

Example #3

‘Normalize function’ can also be used to normalize the values of an attribute in a table. For getting normalized values in this case, we need to pass a few more arguments.

In this example, we will create a table with 5 Indian cities and their respective temperatures. Finally, we will normalize the temperature w.r.t. the maximum temperature in the table.

Code: 

CityName = {‘Delhi’; ‘Mumbai’; ‘Bengaluru’; ‘Chennai’; ‘Hyderabad’};

[Defining the column 1 of the table]

Temperature = [43; 38; 27; 40; 41];

[Defining the column 2 of the table]

Tab = table (CityName, Temperature)

[Creating the table]

NormalizedTemp = normalize (Tab, ‘norm’, Inf, ‘DataVariables’, ‘Temperature’)

[Using the normalize function for the table ‘Tab’. Note that, here we have passed 3 new arguments: ‘Inf’, ‘DataVariables’, ‘Temperature’, this will tell MATLAB to normalize the ‘temperature’ attribute w.r.t the maximum temperature in the column].

Input:

CityName = {'Delhi'; 'Mumbai'; 'Bengaluru'; 'Chennai'; 'Hyderabad'};
Temperature = [43; 38; 27; 40; 41];
Tab = table (CityName, Temperature)
NormalizedTemp = normalize (Tab, 'norm', Inf, 'DataVariables', 'Temperature')

Output:

MATLAB Normalize 6

MATLAB Normalize 7

As we can see, our column values are normalized with highest value being 1.

Conclusion

MATLAB provides us with ‘normalize’ function to normalize the vectors or arrays. We can also use the methods like ‘range’, ‘scale’, ‘center’ in the argument depending upon the type of output we expect.

Recommended Articles

This is a guide to MATLAB Normalize. Here we discuss the introduction to MATLAB Normalize along with programming examples respectively. You may also have a look at the following articles to learn more –

  1. Covariance in Matlab
  2. Filter Function in Matlab
  3. Matlab mesh()
  4. Plot Vector Matlab

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - ENROLL NOW