Ask Programming Language Expert

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

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M91987502
  • Price:- $25

Priced at Now at $25, Verified Solution

Have any Question?


Related Questions in Programming Language

Assignment - haskell program for regular expression

Assignment - Haskell Program for Regular Expression Matching Your assignment is to modify the slowgrep.hs Haskell program presented in class and the online notes, according to the instructions below. You may carry out th ...

Assignment task -q1 a the fibonacci numbers are the numbers

Assignment Task - Q1. (a) The Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and are characterised by the fact that every number after the first two is the sum of the ...

Question - create a microsoft word macro using vba visual

Question - Create a Microsoft Word macro using VBA (Visual Basic for Applications). Name the macro "highlight." The macro should highlight every third line of text in a document. (Imagine creating highlighting that will ...

Assignmentquestion onegiving the following code snippet

Assignment Question One Giving the following code snippet. What kind of errors you will get and how can you correct it. A. public class HelloJava { public static void main(String args[]) { int x=10; int y=2; System.out.p ...

Assignment - proposal literature review research method1

Assignment - Proposal, Literature Review, Research Method 1. Abstract - Summary of the knowledge gap: problems of the existing research - Aim of the research, summary of what this project is to achieve - Summary of the a ...

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Task silly name testeroverviewcontrol flow allows us to

Task: Silly Name Tester Overview Control flow allows us to alter the order in which our programs execute. Building on our knowledge of variables, we can now use control flow to create programs that perform more than just ...

Structs and enumsoverviewin this task you will create a

Structs and Enums Overview In this task you will create a knight database to help Camelot keep track of all of their knights. Instructions Lets get started. 1. What the topic 5 videos, these will guide you through buildi ...

Task working with arraysoverviewin this task you will

Task: Working with Arrays Overview In this task you will create a simple program which will create and work with an array of strings. This array will then be populated with values, printed out to the console, and then, w ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As