Page 37 -
P. 37

y=a*sin(th);
                                   z=(1+A*cos(w*(t-1)))*th;
                                   plot3(x,y,z,'r');
                                   axis([-2 2 -2 2 0 40*pi]);
                                   M(:,t)=getframe;
                                   end
                                movie(M,15)

                              The statement M=moviein(16) creates the 2-D structure that stores in
                             each column the data corresponding to a frame at a specific time. The frames
                             themselves are generated within the for loop. The getframe  function
                             returns a pixel image of the image of the different frames. The last command
                             plays the movie n-times (15, in this instance).






                             1.10 Histograms

                             The most convenient representation for data collected from experiments is in
                             the form of histograms. Typically, you collect data and want to sort it out in
                             different bins; the MATLAB command for this operation is hist. But prior to
                             getting to this point, let us introduce some array-related definitions and learn
                             the use of the MATLAB commands that compute them.
                              Let {y } be a data set; it can be represented in MATLAB by an array. The
                                    n
                             largest element of this array is obtained through the command max(y), and
                             the smallest element is obtained through the command min(y).
                              The mean value of the elements of the array is obtained through the com-
                             mand mean(y), and the standard deviation is obtained through the com-
                             mand std(y).
                              The definitions of the mean and of the standard deviation are, respectively,
                             given by:

                                                     N
                                                    ∑  yi ()
                                                 y =  i=1
                                                       N
                                                         N
                                                                    N
                                                        ∑       2  −  ∑   2
                                                       N    ((         y i ( ) 
                                                            y i))
                                                 σ  =    i=1        i   =1  
                                                  y
                                                               (
                                                             NN − ) 1
                             where N is the dimension of the array.

                             © 2001 by CRC Press LLC
   32   33   34   35   36   37   38   39   40   41   42