Each of the problems below is intended to be solved by generating a script or m-file. Be sure to have a very clearly written header for each M-file so that anyone reading your work can decipher the sort of problems you are solving in each M-file. Also, be sure to label all axes and assign each plot a title.

A complete set of m-file solutions can be found here. Of course, your work does not have to look exactly like these scripts but the results (e.g. plots) should look much the same. Don’t be lazy and start by looking at these answers … only refer to these solutions if you get stuck or want to check your finished work.

  1. This homework assignment has two major parts. The first part will explore some of MATLAB's built-in statistics functions. We will also look at how to plot histograms. For this first part read the HELP pages on the following functions (either by typing "help" and then the function name at the MATLAB command prompt, or by clicking these links): mean, median, std, min, max, sum, cumsum, hist, rand, randn, bar and barh. The second part will explore how to use MATLAB to plot 3-dimensional graphs. For this second part read the HELP pages on the following functions: mesh, contour, meshc, surfc, view, surf and format (and all it's options).

    For problems # 2-8 we are going generate a matrix of random numbers using both the RAND and RANDN functions. We'll calculate some simple statistics and then generate a histogram to show us how these random numbers are distributed. Submit a single M-file and two separate plots. Note the instructions below regarding using the SUBPLOT command. As always, be sure to provide labels and titles for your graphs. Click here to see what your resulting plots should look like.
  2. Using the RANDN function, generate a 1-by-2000 matrix of random numbers and call it X. Yes, this is just an "array" of 2000 random numbers.
  3. Provide some simple statistics on this data by calculating the mean, median and standard deviation of this random set of numbers.
  4. Generate an array called BINS that goes from the minimum value of X to the maximum value of X in steps of 0.1.
  5. Using the HIST (histogram) function, generate a set of X_values and Y_values that you'll use to plot out the histogram. The command will look something like this: [Y_values, X_values] = hist(X, BINS).
  6. Now, using the LENGTH command, "normalize" the set of Y_values. You do this by dividing Y_values by the number of data points in your original array X.
  7. Use the BAR command along with the X_values and the normalized Y_values to plot out the histogram. Here, I want you to use the SUBPLOT command to put this first of two graphs (see next problem, there will be two graphs, one above the other) on the top of the plot page.
  8. Now, using the CUMSUM command I want you plot the cumulative sum of the normalized Y_values values as a function of the X_values (i.e. X_values will still be on the horizontal axis).
  9. Now repeat the previous seven steps but this time start out by using the RAND function instead of the RANDN function to generate your matrix of random numbers.

    For problems # 10-17 we are going generate the data for two different 3-D graphs and then look at them from different angles. Submit a single M-file that evaluates both functions and eight separate plots .... if you prefer use the SUBPLOT command and put four of the plots on one page. As always, be sure to label the axis and title your graph. Click here to see what your resulting plots should look like.
  10. Generate an array X that goes from 1 to 100 in steps of 1.
  11. Generate two new arrays where Y = X2 and Z = Y3.
  12. Using the MESH command, plot X vs Y vs Z*X. Here, X and Y will be on the HORIZONTAL plot plane and the product Z*X will be the vertical. Remember, when using the MESH command the first two variables (in this case X and Y) have to be arrays and the third variable (in this case X*Z) has to be a MATRIX with dimensions bounded by the size of X and Y. So, when you multiply Z and X you are going to have to TRANSPOSE one of these in order to produce the SQUARE MATRIX you'll need to generate the plot.
  13. Now, using the VIEW command, plot out (i.e. print) four different   viewing angles for this 3-D plot.
  14. Now, we're going to generate a 3-dimensional plot of time constant values for an RC (i.e. Resistor-Capacitor circuit). You will be using this plot during your design work in the next third of this class when you'll study Pspice.
  15. Generate the following arrays: R that goes from 1 to 1000 in steps of 1, C that goes from 1e-9 to 1e-6 in steps of 1e-9, and a matrix Z that consists of all possible combinations of R*C.
  16. Using the MESH command, plot R vs C vs Z.
  17. Now, using the VIEW command, plot out (i.e. print) four different viewing angles for this 3-D plot.

To continue on to the next core lesson, click here.