MATLAB Statistical Functions

The following tutorial is an introduction to MATLAB functions such as average, standard deviation, maximum, minimum, and conditional counting.

MATLAB Source Code

 % clear session and screen
 clear all; clc
 % create a new column vector with 10 elements
 %  with random numbers between 0 and 100
 y = rand(10,1) * 100;
 % basic statistics
 % define a new anonymous function
 avg = @(x) sum(x)/length(x)
 % check new function
 disp('Average with avg function: ')
 disp('Average with mean function: ')
 % number of values below 50
 % boolean vector of 0 or 1 values
 % display result
 disp('Number of values below 50: ')
 z = y<50;

Custom MATLAB Functions

User-defined MATLAB functions are custom routines that accept inputs, perform some type of specialized calculation, and return and output. This tutorial exercise demonstrates how to create a custom script file and use it to perform custom calculations.

Additional Tutorials

Data statistics can also be completed with a spreadsheet program like Microsoft Excel and Python where the data sets are arrays or matrices instead of tables in a spreadsheet. Click on the appropriate link for additional information and source code.