EE 289

Homework Assignment 4
Due Sep. 23, 2010 Read pages 17-27 of Pratap, "Getting Started with Matlab"

  1. Exercise 1, Page 27.
  2. Exercise 3, Page 27.

    To square the elements of an array, use .^2 instead of ^2. To multiply two arrays, use .* insteade of *. For example,

    x = 0:0.01:1;  % x goes from 0 to 1 by steps of 0.01
    y = x.^2;      % Each element of y is the corresponding element of x squared
    z = x .* y;    % Each element of z is the corresponding element of x times y.
                   % For example, z(3) will be x(3)*y(3)
    
  3. Exercise 7, Page 27.

    The easier way to do this is to plot one curve, give the command "hold on", then plot the second curve.

    plot(x,y)
    hold on
    plot(x,z)
    
    You should plot the first curve in blue and the second curve in red. (To plot in red, give the command
    plot (x,z,'r')


Bill Rison, <rison@nmt.edu >