matlab2 - Matlab Project 2 EB 228-O4 j gh‘ The purposes...

Info icon This preview shows pages 1–2. Sign up to view the full content.

Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Matlab Project 2 EB 228-O4 j gh‘ 4/7/06 The purposes of these team Matlab project assignments are to introduce the student to the use of Matlab, to use Matlab as a tool to learn the theory presented in lecture and to analyze more complicated systems than pencil and paper conveniently allow, and to introduce the student to team project work. The BB 228 class is to form into two or three person teams for the Matlab assignments; teams can be greater than three, but the larger teams will require the prior approval of the instructor. For the submittal of each assignment, each team will submit one report, with each team member providing one thoughtful, reflective paragraph discussing what they have learned. All students are to read Chapter 21in their text. Matlab is available on computers in the Digital Senior Project Lab (20-118) which should be open from 8:00am to 6:00pm Monday through Friday, and from 9:00am to 1:00pm Saturday. The BB 368 lab (20-113) also has a copy of Matlab installed on each of its machines. Access to the BB 368 lab will be limited to periods outside scheduled lab times. Request access to the lab at the Senior Project window —— your name should be on a list from the ER 228 class list. The team members are to learn the use of the Matlab through the online documentation and/or the Matlab supplied tutorial and/or through the use of the text material in Chapter 21. Before creating the m-file convprojm below, each team will have to create the Matlab function trih. In addition to the m-files which are scripts of commands, there canbe m-files which are defined to be matlab functions. The name of the m-file and the function are the same. Below is an example of a function which can be used to calculate your textbooks tri(t) function. The file is named trih.m, and is to be saved in the work directory (which should be a directory accessed in your local path environment). The function is named trih also. The format for the matlab function code is given with the trih.m file as shown below: function y=trih(t) %TRIH triangle function centered at t=0 from t=-l to t=+1 with %trih(0)=1. % usage: % y = trih(t) % where: % t = input vector % y = output vector if (nargin==0 l nargin>l) %check that there is only one argument error('only one input argument, a vector') %error output to user end x=abs(t); %two lines of code from Ambardar code for tri(x) y=(1-x).*(x<=l); %note logic x<=l is 1 if true and 0 if false Some things that'you should note are: _ 1) the format of the first command line and subsequent comment lines — these are shown if the command help trih is entered 2) the error check on the number of arguments and the output text for error explanation to the user 3) the use of the ; to inhibit the user output 4) the need to define the input vector t prior to the use of the function; also, the argument does not have to be named t, but could be entered as z . 5) likewise, the output variable does not have to be named y, but could be entered as f. Note also that the name of the function is trih, which Will not conflict with the adsp function tri. If you do not have the adsp functions available, then you can enter the function name as tri(t). Note that you could still enter the function as tri(t), save it in your work directory, and there would be no conflict. Enter the code for the m-file and save it in your work directory. Then execute the following commands and observe the results: help trih = -2:0.01':2; y = trih(t); plow, y) y = trih(x,t); plot(t, 4*trih(2*t- l ))' .Now that the team has the function trih available in their work directory, the team is to enter the following Matlab m-file code and execute it. The report is to consist of a commented version of the m-file code with the added code for the annotation, a plot of the output with suitable annotation for the title and axis, and the thoughtful, reflective individual paragraph from each of the team members discussing what they have learned from the experience. The report is due Friday April 21, 2006. %script: convprij _ a % continuous convolution of x(t) with h(t), y(t) = x(t) * h(t), note that the output % range must be determined explicitly, i.e., range of the time value for the output y(t) ts=0 .0 1 ; tx=-1 :ts: 1; th=02ts:2; x=3 *cos(pi*tx/2); h=trih(th- l ); y=ts*conv(x,h); ty=-l :tsz3; plot(tx,x,th,h,ty,y); gtext('x(t)') gtext('h(t)') gtext('y<t)'> l l l i 1 l l \ l ...
View Full Document

  • Spring '08

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern