Digital Signal Processing Reference
In-Depth Information
ans =
10
>> max(x)
ans =
90
Now we will put it in a function:
%
% Return a vector of m random values
% between low and high.
%
% Usage: result = myrand(low, high, m)
%
function result = myrand(low, hi, m)
result = round(rand(1,m)*(hi-low) + low);
8. With an array of 8 values between 0 and 99 (use \myrand"), write a function
to return the values in sorted order, from lowest to highest.
Answer:
%
% mysort.m
%
% Given an array of numbers, sort them.
% (Use a bubble-sort since it is simple).
%
function sorted = mysort(unsorted)
sorted = unsorted;
done = false;
Search WWH ::




Custom Search