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 Standard Deviation
 

Matlab Standard Deviation

Updated March 6, 2023

Matlab Standard Deviation

 

 

Introduction to Matlab Standard Deviation

Standard deviation is used to measure the spread in statistics. Spread, also referred to as “Dispersement”, tells us how much our data points are spread out around the average or mean. A ‘Bell curve’ is used to study the standard deviation in Statistics. In Matlab, we use the ‘std’ function to compute the standard deviation of a vector or a data set. In today’s world, the standard deviation is extensively used in data analytics to create sophisticated Artificial Intelligence based algorithms.

Watch our Demo Courses and Videos

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

Syntax of standard deviation function:

SD = std (X)

SD = std (X, w)

Explanation:

  • SD = std (X) is used to compute the standard deviation of the elements of ‘X’. Here, ‘X’ can be a vector, matrix, or multidimensional array.
  • SD = std (X, w) is used to compute the standard deviation of the elements of ‘X’ with a weightage of ‘w’.

Please note that, by default, the standard deviation will be normalized to N-1, N being our number of observations.

Examples of Matlab Standard Deviation

Given below are the examples of Matlab Standard Deviation:

Example #1

In this example, we will use the std function to compute the standard deviation of elements of an array.

Below are the steps to be followed:

  • Initialize the input array.
  • Pass this input array as an argument to the standard deviation function.

Code:

X = [7 -5 11 2 6 5 -8 0 17 5] [Initializing the input array with 10 elements]

SD = std (X)
[Using the std function to compute standard deviation for the elements of the input array]

Input:

Matlab Standard Deviation 1

Output:

Matlab Standard Deviation 2

As we can see in the output, 7.2877 is the standard deviation of the elements of our input array.

Example #2

This example will use the std function to compute the standard deviation of 3 x 3 matrix elements.

Below are the steps to be followed:

  • Initialize the input 3 x 3 matrix.
  • Pass this input matrix as an argument to the standard deviation function.

Please note that, for a matrix, the std function will compute the standard deviation of elements along each column.

Code:

X = [5 -5 1; 0 4 3; 8 10 4] [Initializing the input 3 x 3 matrix]

SD = std (X)
[Using the std function to compute standard deviation for the elements of the input matrix]

Input:

3 x 3 matrix

Output:

Matlab Standard Deviation 4

As we can see in the output, we have obtained the standard deviation of the elements of our input matrix along with the columns.

Example #3

In this example, we will use the std function to compute the standard deviation of elements of a 3-Dimensional array.

Below are the steps to be followed:

  • Initialize the input 3-Dimensional array.
  • Pass this input 3D array as an argument to the standard deviation function.

Code:

X (:, :, 1) = [1 5 3; 2 0 1; 2 2 2];
X (:, :, 2) = [19 3 3; 5 1 3; 3 5 1];
X (:, :, 3) = [0 4 1; 2 -3 1; 2 4 7];
[Initializing the input 3 x 3 matrix]

SD = std (X)
[Using the std function to compute standard deviation for the elements of the input 3D array]

Input:

3-Dimensional array

Output:

Matlab Standard Deviation 6

As we can see in the output, we have obtained the standard deviation of our 3-D input array elements along with the columns.

In the above 3 examples, we have not provided any weightage while computing the standard deviation.

Let us now see how to assign weightage in the std function.

Example #4

In this example, we will use the std function to compute the standard deviation of a 3 x 3 matrix elements and assign some weightage to it.

Below are the steps to be followed:

  • Initialize the input 3 x 3 matrix.
  • Initialize the weightage vector.
  • Pass the input matrix and weightage vector as arguments to the standard deviation function.

Code:

X = [2 15 4; 1 6 4; 1 -5 2];
[Initializing the input 3 x 3 matrix]

w = [0.7 1 1.5];
[Initializing the weightage vector]

SD = std (X, w)
[Using the std function to compute standard deviation for the elements of the input matrix. We have also passed weightage vector ‘w’ as the second argument]

Input:

Matlab Standard Deviation 7

Output:

assign some weightage

As we can see in the output, we have obtained the standard deviation of our 3 x 3 matrix elements with assigned weightage.

Conclusion

We use the std function to compute the standard deviation of an array, vector, or matrix elements. The standard deviation, by default, will be normalized to N-1, N being our number of observations.

Recommended Articles

This is a guide to Matlab Standard Deviation. Here we discuss the introduction and examples of Matlab standard deviation, respectively. You may also have a look at the following articles to learn more –

  1. What is Matlab?
  2. Matlab limit
  3. Plot graph Matlab
  4. Absolute Value 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