Skip to content

Latest commit

 

History

History
13 lines (12 loc) · 2.78 KB

Statistics.md

File metadata and controls

13 lines (12 loc) · 2.78 KB

Statistics in MATLAB

Function Definition Example
mean(data) Calculates the mean (average) of the elements in the data. data = [1, 2, 3, 4, 5];
result = mean(data); % Result: 3
median(data) Computes the median value (middle value) of the data. data = [1, 2, 3, 4, 5];
result = median(data); % Result: 3
std(data) Calculates the standard deviation, a measure of data spread. data = [1, 2, 3, 4, 5];
result = std(data); % Result: 1.4142
var(data) Computes the variance, a measure of data variability. data = [1, 2, 3, 4, 5];
result = var(data); % Result: 2.5
min(data) Finds the minimum value in the data. data = [1, 2, 3, 4, 5];
result = min(data); % Result: 1
max(data) Finds the maximum value in the data. data = [1, 2, 3, 4, 5];
result = max(data); % Result: 5
hist(data, bins) Creates a histogram of the data with the specified number of bins. data = [1, 2, 2, 3, 3, 3, 4, 4, 5];
hist(data, 5);
corrcoef(data1, data2) Calculates the correlation coefficient between two datasets. data1 = [1, 2, 3, 4, 5];
data2 = [5, 4, 3, 2, 1];
result = corrcoef(data1, data2);
anova1(data, group) Performs one-way analysis of variance (ANOVA) on the data grouped by a categorical variable. data = [1, 2, 3, 4, 5];
group = [1, 2, 1, 2, 1];
p = anova1(data, group);