Eeng 330 microelectronics - create a frequency vector


Lab #1: Introduction to MATLAB

Lab objectives: At the end of this lab you should be able to
- Open MATLAB and setup a working directory
- Manipulate variables, vectors and matrices in MATLAB including indexing.
- Call built-in MATLAB functions
- Plot graphs using MATLAB with axis labels, legends, and title.
- Write MATLAB scripts and functions and call your function

Read the Introduction to MATLAB Handout on canvas, paying particular attention to how to index arrays and how to write functions.

Open a MATLAB script file and name it Lab1_YourName.m. Use this to enter every MATLAB command you execute in this lab. Do NOT use the command line interface, because you need to turn this m-file in with your submission.

Part#1: Variable Assignment:

1) Start your script file with a clear; close all; clc;

The first clears the workspace, the second closes all plot windows, and the third clears the command line screen.

2) Create a matrix called M1 that has the following elements

M1 =

 

 

17

11

5

9

 

10

13

7

6

 

4

18

2

16

Create a matrix called M2 which is the transpose of M1.

3) Create a vector called v3 which has one row and whose columns contain the elements 5,10,15..... 150 (there should be 30 columns in this vector).

4) Create a frequency vector called, omega which has one row and whose columns contain the elements 0.0, 0.02, 0.04, ..., 7.0 such that MATLAB does not print out the result in the command window. Ensure code is shown in M-File.

Show the results to your instructor and get sign-off. You can move ahead to the next step if the instructor is busy.

Part#2: Math functions and plotting:

In this section, use commands such that MATLAB does not print out results to the command window.

5) Create a matrix the same size as omega called, Volt_omega which has the values, 2+j*omega, in it for the values of omega created previously. Plot the magnitude response abs(Volt_omega) versus omega. Include a title of the form Magnitude response". Label the horizontal axis ‘Radian Frequency (\omega)' and the vertical axis 'abs(2+j\omega)'. Notice how MATLAB changes the \omega to the symbol ω.

6) Create variables Is =1E - 14, VT =26E-3, and a voltage vector that start at -5 volts, with a step size of 0.001, and stops at 2 volts.

Then calculate I = IsV/VT -1 , which is the equation governing the current through a diode relative to voltage applied across it. You should use the command "figure" to create a new plot window and then plot the current versus the voltage with an appropriate title, and axis labels.

7) Notice how the current explodes and there is not a good understanding of what is going on. Here we will scale the axis to a reasonable range of current (i.e. +/- 1A). In a new figure, plot I versus V again, the use the axis command to set the axes limits. axis([min_X max_X min_Y max_Y]) or axes([-5 2 -1 1]). Add a title and axis labels, by programming them in your m-file.

Show the results to your instructor and get sign-off. You can move ahead to the next step if the instructor is busy.

Part#3: M-files: Functions and Vector For-Loops.

The objective of this section is to write a function that calculates the I-V curve for a diode across different temperatures. The function will return a matrix of I-V curves, where the columns represent each temperature.

It is critical that you know when to use a "row-vector" or a "column-vector". Most problems with vector based loops arise when you think it is a row-vector and it is a column vector or vice versa. MATLAB will complain about a dimension mismatch.

8) Write a function, called diode I_V.m, that takes three inputs and returns two outputs. The first input will be a scalar constant for the reverse saturation current, Is. The second input will be a vector of voltages. The third input will be a vector of temperatures in degrees Kelvin.

The function should return a matrix, whose columns are the I-V curves at each temperature and return a temperature vector that is a copy of the input temperature.

The diode current equation is

I = I(qV/ekT -1)

Where q is the charge of an electron (1.6E-19 Coulombs/electron), k is Boltzmanns constant (1.38E-23 J/K or 8.62E-5 eV/K), and T is the temperature in degrees Kelvin. Use kT/q = 26mV at T=300 K to determine which version of k to use.

Notice, this is always an issue in semiconductors.

Be sure to add appropriate comments at the beginning of your function. See the example in the MATLAB introduction handout provided.

Inside your function define q and k appropriately.

9) Write a vector For-Loop that does the following.
- Before the for-loop, create a figure, and make sure MATLAB holds the plot. figure; hold on;

- Create a loop for each parameter in the magnitude vector. i.e. "for ii = 1:length(Temperature Variable)"

- Calculate the required I_V curve versus voltage for a given temperature.

Use either I_V(ii,:) or I_V(:,ii) to store each I-V curve. One will create a matrix whose columns are the I-V curve and the other will create a matrix whose rows are the I-V curve. Pick the right one.

Comment on what "ii" is doing in this section.

- Plot your newly calculated I-V column vector versus voltage inside the for-loop. Make sure each new column-vector plot is on the same graph.

- end your for-loop properly.

- Finally, label the x-axis, y-axis, include a title with your name in it, and scale the axes so the current range is +/- 1 Amp. For example, if your voltage variable is called "Volt", then axis([min(Volt) max(Volt) -1 1]) will give you the minimum and maximum values of the x-axis.

10) Call this function from the Lab1 M-File using the following parameters. Note: It is the location of the variable name in the function, and not the name that matters when passing parameters to a function.

V = [-5:.001:1.85]; %Applied voltage across diode

T = [10, 100, 300, 400]; %Temperature vector

Is = 1E-15; %Reverse bias saturation current

I_V_Data = diode_I_V(Is,V,T);

Notice we place a semicolon to not print result to command window.

Attachment:- code.rar

Solution Preview :

Prepared by a verified Expert
Programming Languages: Eeng 330 microelectronics - create a frequency vector
Reference No:- TGS01625632

Now Priced at $25 (50% Discount)

Recommended (90%)

Rated (4.3/5)