A7

ENGR 17
Assignment 7
Due: Next Tuesday
1) Plotting Multiple Curves, Line Types, Labelling, Legend
For this problem we'll need to plot two curves: revenue (what we get from selling the product) and cost (how much
we spent making it) versus Q, the number of gallons (quantity) of product we've made
Create an A7 folder. Point matlab to thie folder, then create a new .m file called crossover.m and develop your
solution to problem one inside. As you work, make frequent saves and executions to check your solution accuracy.
Before we can generate any curves, we'll have to come up with the values of Q that the two curves will be based on.
What range of Q do we need? Since we expect to see a crossover point, we need to choose values of Q that will get
us close to the break even point. We can just do some quick calculations here to determine about how much
product we'll need. Reading the problem again, fill in the table for the following values of Q:
Q (quantity, gallons)
1 Million
10 Million
100 Million
Cost
Revenue
Use this analysis to choose an approximate range of values for Q (ones that include a crossover from net loss to net
gain). Don't worry about being exact, you can adjust Q values later.
Define your Q vector based on your analysis above. Note that you may want to increase the spacing between Q
values by 1000 instead of the default 1.
Now calculate the revenue and cost vectors using the formulas above. Create a plot of both of these curves using
different line types. Create a legend, and label the crossover point with a text or gtext command in your script.
All of your code should be placed in your script. When you are finished save the plot as crossover.jpg and move on
to the next problem.
2) Multiple Plots, Line Types, Legend, Label
For this problem, create a new .m file in your A7 folder called oscillate.m
Create the plot, experimenting with different time ranges for t and point spacing. If the line looks jagged, increase
point spacing in t.
Use a legend, line types, and line colors to help clarify the two curves. When you are finished, save your plot as
oscillate.jpg.
3) Complex Numbers, Log Plots, Subplots
For this problem create an .m file called bandPass.m. Inside this file you may hard code the values for R, L and C.
Create the w vector over the range specified. You may wish to use the logspace command which spaces values
logarithmically. Remember to use the abs command to take the magnitude of the complex vector you are
calculating.
Create two side-by-side subplots. In the first, plot the magnitude vs w on a linear scale, add labels and title. Then, in
the second subplot, replot the data on a loglog scale, add labels and title. When you are finished you should see the
advantage of using logarithmic scales in plotting data with very wide dynamic range. Save your plot as bandPass.jpg
4) Plotting Data, Multiple LInes, Line Types, Markers
For this problem, create an .m file called elongation.m. Here we will plot experimental data. The first column will be
the x-axis and the second two will be the y-axis. Use data markers such as triangles for the data points, and line
colors and line types to make the two curves easy to distinguish. Also, add a legend to help clarify the message the
plot is conveying. Save the plot as elongation.jpg.
5) (1 pt extra credit) Create an .m file called sine.m and inside, create 3 side-by-side subplots according to the
following directions. Use different linetypes where needed to keep the multiple curves distinct.