MATLAB Chapter 12

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Variance

(x1-mean)^2/(n-1)+(x2-mean)^2/(n-1)...(xn-mean)^2/(n-1)

Geometric mean

nth root of (x1*x2*x3...xn) This can be implemented using an anonymous function.

How can you sort something manually in ascending order (selection sort)?

1) Find the smallest number if the vector and exchange it with the one in the first position by using temporary variables. 2) Find the next smallest value, and exchange it with the second element of the vector. 3) Continue doing this, and once the next to last number has been placed in the correct location, the last number, by default, has been as well.

sort(vec)

A built-in function that sorts a vector in ascending order.

hist(y,m)

Bins the elements of y into 10 equally sized "containers" if there is no m. In a matrix, it works columnwise to do this. If m is a scalar, it bins it into that many containers. If m is a vector, it centers it there. histc is used to specify edges instead.

help datafun

Brings up statistical functions

std(array)

Built-in function calculating the standard deviation.

What can be done with outliers in a dataset?

Discard the largest and smallest values of the array, leaving only the ones in the middle in the array. Sometimes the largest 1% or 2% are removed if the dataset is larger.

sort(char('Hello','Howdy','Hi','Goodbye','Ciao')

Ce Giad Hildb Hoolo Howoyye

median

Defined only for a data set that has been sorted first, meaning that the values are in order.

What does standard deviation show?

How spread out a data set is.

mode(array)

Finds the value (not the index) in the array that appears the most frequently. When there are two values that appear with the same highest frequency, the smaller value is the mode (e.g. 3 vs 8, it is 3) Therefore, if no value appears more frequently than any other, the mode of the vector will be the same as the minimum.

median(array)

If the length of the array is odd, then the median is the middle value. If the length of the array is even, the median is the average of the two middle values. If the vector is not in sorted order to begin with, the median function will still retrn the correct result (sorting the vector automatically)

[outvec index1 index2]=intersect(vec1,vec2)

It returns the resulting vector in outvec, the indices of these values in vec1 in index1, and the indices of these values in vec2 in index2.

Sorting

Process of putting a list in order, either descending or ascending.

issorted(vec)

Retuns logical 1 for true if the argument is sorted in ascending order, and 0 if not.

min/max functions

Return the index of the smallest/largest value; if there is more than one occurrence, it returns the first index in which it is found.

ismember(vec1,vec2)

Returns a logical vector that is the same length as the first argument, containing logical 1 for true if the element in the first vector is also in the second, or logical 0 for false if not. Using this result as an index into the first vector argument will return the same values as the intersect function (though not automatically sorted)

setxor(vec1,vec2)

Returns a vector consisting of all of the values from the two vectors that are not in both of the two vectors as sorted, unless using 'stable'.

setdiff(vec1,vec2)

Returns a vector consisting of all of the values that are contained in the first vector argument but not the second, therefore the result will depend on the order of the arguments, and this is sorted, unless using 'stable'.

union(vec1,vec2) union(vec1,vec2,'sorted')

Returns a vector that has all the values from the two input argument vectors without repeating any. By default, the result is in sorted order, so the arguments can be passed in any order.

unique(vector)

Returns all of the unique values from a set argument (takes out repeating) sorted, unless use 'stable'

intersect(vec1,vec2)

Returns all of the values that can be found in both of the two input argument vectors in sorted order, unless using 'stable'.

What are the results for sorting different vectors.

Row for row, column for column.

sortrows(wordmat)

Sorts entire strings alphabetically, by examining the stirings column by column starting from the left, so each 'row' is sorted alphabetically from left to right. When used on a normal matrix, it sorts it based on numerical order, but lifts each row like it does with wordmat.

var(array)

The built-in function used to calculate the variance.

mean(x,n)

This finds the arithmetic mean of an array x. In a matrix, it operates columnwise. To find the mean of each row, 2 is passed in n, otherwise it is left blank. This is the case with sum,prod,cumsum,cumprod.

union(vec1,vec2,'stable')

This is just like a normal union vector, except the result would be in the original order, so that the order of arguments would matter, and the final vector is not sorted.

sort(cell)

This sorts a cell array of strings by alphabetical order.

sort(vec,'descend')

When specified, this built-in function sorts a vector in descending order. For matrices, it ill sort each column, unless specifying the second dimension.

Can vectors of structures also be sorted?

Yes, each structure can be exchanged depending on one field, but not by using the sort() function.

Can strings be sorted?

Yes, you can use the sort function, which sorts each character in a string by their ASCII equivalent. It sorts columnwise for matrices, unless otherwise specified.

Harmonic mean

n/(1/x1+1/x2+1/x3...1/xn) This can be implemented using an anonymous function.

Standard deviation

sqrt(variance)


संबंधित स्टडी सेट्स

Human Anatomy: Musculoskeletal Cases

View Set

1 - Escoger (Chapter 3)Audio You will hear some questions. Select the correct answers below based on the family tree.

View Set

Lecture 12: Brain and Cranial Nerves e.) Cranial Nerves

View Set

Lincoln Way Physical Education Swim Test

View Set

Chapter 4 Plate Tectonics and Earthquakes

View Set

He Lion, Bruh Bear, and Bruh Rabbit

View Set

(B) DPHY Chapter 9 & 10: Heart Muscle & Rhythmic Excitation

View Set

Cell recognition and the immune system

View Set