Introduction to Matlab
1. Create the vector x = [1,2,...,100]. Assign the even numbers of x to a
new vector y.
2. Use for loop to find the values of for t = 0, 01,
0.2, 0.3, 0.4 s when f =10, 15, and 20 Hz. Use one set of statements to
compute the values for all three frequencies and store the results in a two-dimensional
array. Use two nested for loops and double indexing.
3. Use while loop to find the largest value of positive t for which and
are both less than 10. Make the computation for ω=35, 40, and 45. Find your
answers to the nearest 0.01.
4. Create a 15-element vector with values of
at equally spaced interval . Find the maximum element value, the minimum
element value, the average of the element values, and the indices of the elements for
which the element magnitude is greater than 4.
5. Assume , and , where
and . Plot , and v/s with
on the same graph (you have to use hold on command). Label the axes and create
legends for each graph.
6. Sinc function is a function that arises frequently in our course. It is defined as
Create a Matlab function MySinc () that defines sinc(x) function following
the above definition. Plot the value sinc(x) in the interval [-2π 2π] using
MySinc () function and Matlab inbuilt sinc() function on the same graph. 学霸联盟