Sie sind auf Seite 1von 1

Using Matlab as a Research Tool Some Pseudocode for the Function UniqueValues

1. To return only a vector of unique values: Accept a matrix A Convert A to a column vector Initialize an empty vector u For each of the values in A, If the current value in A is not in u, Concatenate the value to u End if End for Return u 2. A slightly more efficient version: Accept a matrix A Convert A to a column vector Initialize a vector u to the first value in A For each of the remaining values in A, If the current value in A is not in u, Concatenate the value to u End if End for Return u 3. To return both the unique values and their frequencies: Accept a matrix A Convert A to a column vector Initialize a vector u to the first value in A Initialize a vector f to the value 1 For each of the remaining values in A, If the current value in A is not in u, Concatenate the current value to u Concatenate the value 1 to f Else Find the current value in u Increment the corresponding value in f End if End for Return u

Das könnte Ihnen auch gefallen