Matlab Problem

Matlab Problem
ECE 102 ENGINEERING COMPUTATION
STANDARD HOMEWORK #3
ECE DEPARTMENT
PORTLAND STATE UNIVERSITY
WINTER 2017
ECE 102 Standard Homework #3 Winter 2017
1
ECE 102 Standard Homework #3 (HW-s3)
Problem List
15 pts Problem #1 – Curve fitting
15 pts Problem #2 – Plotting data from a file
15 pts Problem #3 – Bad graphs
5 pts Following presentation format rules
General Instructions
For Problems #1 through #3:
a) Unless otherwise specified, you must show your equations and calculations to get full credit.
b) Solutions should be either hand-written on engineering paper or printed out using a computer.
c) Follow the presentation format discussed in the “Problem Solving” lecture.
o For Problems #1 and #2, you may omit the Solution Check and Discussion.
o For Problem #3, omit the Solution Check, but discuss your results.
o For significant figures, you are allowed to do all of the calculations first and then
round off at the end.
d) Either draw a double underline beneath or box the final answers you want graded.
e) Staple your paper sheets together.
f) Submit your solutions to the Instructor at the beginning of class on the due date.

ECE 102 Standard Homework #3 Winter 2017
2
Problem #1
The following table shows measured data for Im versus Vm.
X-15 Gadget: Current vs. Voltage
Measured voltage Vm
(V)
Measured current Im
(A)
1.00 8.26×10-2
1.45 3.32×10-2
2.15 1.31×10-2
2.50 5.94×10-3
3.05 2.56×10-3
3.55 1.22×10-3
3.94 5.11×10-4
4.53 2.17×10-4
4.97 9.64×10-5
a) Write a MATLAB program that uses subplot to draw a 2×2 grid of Im versus Vm using:
• linear-linear axes
• semilog axes (both lin-x,log-y and log-x,lin-y)
• log-log axes
Apply the principles of making “good” graphs (i.e., full axes labels, titles, markers, etc.).
For fun, use a different marker type and marker color for each subplot. Also, turn on the grid
to make it easier to see the scale divisions.
Attach a printout of your graph to your paper assignment.
Upload your MATLAB program to the appropriate D2L dropbox.
b) From examining the graphs, what type of functional relationship exists between the
independent and dependent data (i.e., is it linear, power, or exponential)?
c) Calculate the numeric fitting parameters (i.e., m and b) for your selected relationship.
• Derive the correct curve fitting equations.
• You may perform calculations first and then round-off at the end.

ECE 102 Standard Homework #3 Winter 2017
3
Problem #2
A MOSFET (Metal-Oxide-Semiconductor Field-Effect Transistor) is an active electronic
component that can be used either as a digital switch or as an amplifier.
For an NMOS transistor, applying a positive VD voltage causes a current ID to flow. The amount
of current is controlled by the gate voltage VG.
The drain current versus the drain voltage (i.e., ID versus VDS) is important when describing the
performance of the transistor. Typically, the data is measured for several values of gate voltage
(VG). The resulting “characteristic curves” are plotted on the same graph, similar to Figure 2.
Figure 2: NMOS characteristic curves1
1

The MOSFET


Figure 1 shows a three-terminal NMOS-type device. The
terminals are the drain (D), source (S), and gate (G).
ID is the drain current
VDS is the drain-to-source voltage
VGS is the gate-to-source voltage
IDS
VDS
VGS
Figure 1: NMOS symbol
ECE 102 Standard Homework #3 Winter 2017
4
Task
Write a MATLAB program that meets these specifications:
• Prompts the user to enter a file name.
(The file with this name should contain measured ID-VDS data.)
• Reads the raw data from the file and stores it in appropriate arrays.
(Hint: Consider whether multiple 1-D arrays or a single 2-D array is more efficient.)
• Plots the characteristic curves on a graph, which should have these features:
o The 1st line of the title should be “ID-VDS Characteristic Curves”.
o The 2nd line of the title should contain the name of the file.
o The x-axis label should be “Drain voltage VDS (V)”.
o The y-axis label should be “Drain current ID (mA)”.
o The legend should say “VGS = xx V”, where xx is one of the gate voltage values.
o Hint: You can create cell arrays to hold multiple strings for the title and legend.
Attach a printout of your graph that uses data from SSOI2_NMOS_r12c11_50u_450.txt.
Upload your MATLAB program to the appropriate D2L dropbox.
Important:
• Your program should have a title block and reasonable in-line comments.
• Your graph must look as similar to the instructor’s graph style as possible. This includes
marker symbols, font sizes, colors, labels, subscripts in labels, title, legend, etc.
• Your program should work for any data file that follows the format described below.
File Format
You are given two data files to use for testing:
• SSOI2_NMOS_r12c11_50u_450.txt (full set of actual measured values)
• reduced_data.txt (a subset of the SSOI2 file to make it easier for you to experiment with)
The internal organization of each file looks like this:
• The first line always states the number of VGS points.
• The second line always states the number of VDS points.
• The next block lists the gate-source voltage values (one per line).
• The next block lists of the drain-source voltage values (one per line).
• Following those are consecutive blocks of ID data values (one for each VDS) for a given VGS.
Hint: Look at the reduced_data.txt file. Once the raw data is read via dlmread, think about the
array indices that mark the beginning and ending of each block. Since the file tells you the
number of VGS and VDS points, see if you can find a general pattern for determining the indices of
each block. You can then extract the desired data using the indices with the colon range operator.

ECE 102 Standard Homework #3 Winter 2017
5
Organization of data inside the file reduced_data.txt:
3
20
0.2
0.4
0.6
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
-4.4999E-06
0.0024105
0.004164
0.0050964
0.0055165
0.0057485
0.0059149
0.0060484
0.0061636
0.0062652
0.006357
0.006443
0.006525
0.0066071
0.0066941
0.0067866
0.006892
0.0070136
0.0071626
0.0073504

Size information: Line 1 =# of VGS points & Line 2 = # of VDS points
Gate voltage (VGS) values
Drain voltage (VDS) values
Drain current (ID) vs VDS data for 1st VGS value
ECE 102 Standard Homework #3 Winter 2017
6
-4.5975E-06
0.003075
0.0058515
0.0080576
0.009469
0.010198
0.010575
0.010805
0.010965
0.01109
0.011195
0.01128
0.011355
0.011425
0.01149
0.011555
0.011625
0.011705
0.011795
0.011915
-5.2319E-06
0.003409
0.0066636
0.0096126
0.01204
0.013765
0.014775
0.01531
0.0156
0.015775
0.01589
0.015975
0.016035
0.01608
0.01612
0.01615
0.016175
0.016211
0.016245
0.01629

Drain current (ID) vs VDS data for 2nd VGS value
Drain current (ID) vs VDS data for 3rd VGS value
Figure 3: Sample MATLAB plot – Your output should mimic this.
ECE 102 Standard Homework #3 Winter 2017
7
Problem #3
Find two examples of “badly” designed graphs from outside sources. They can be from a
magazine article, a book, a research paper, or a website. If the source is printed material, you can
cut out the actual page, or photocopy it, or scan it. If it is from a website, you can print it out or do
a screen capture.
Perform these tasks:
a) For each graph, list what is wrong with the graph.
b) Choose just one of your “bad” graphs and re-do it either on graph paper or via a graphing
program (e.g., MATLAB). Fix all of the things that are wrong with the original graph. You
may change the type of graph if that enhances understanding of the data.
Here are additional requirements:
• Each graph should be from a different source, e.g., one from a book and another from a
website.
• Only submit graphs that are substantially bad! Each graph should have at least two major
things wrong with it. The worse, the better!

Order from us and get better grades. We are the service you have been looking for.