# The objective of this lab is familiarize you with the procedures

Document Sample

```					CSE 150 MatLab                                                        Spring 2005
Lab 2/21/2005                                                              Quiz 1

Name:

Last 4 digits of your SSN:

Part 1: Closed Book Questions (10 pts)

   For choice questions, circle the letter of the answer you are selecting.
   For true/false questions, if you choose false as you answer, then you
must correct the statement. This can’t be the trivial negation of the
statement, but a change that demonstrates a deeper understanding.
   For explanation questions, use concise sentences to explain what the

1. Let A = [8, 4], B= [10, 3], what is the result of A.*B ? (2 pts)

[80, 12]

2. ( TRUE ) – ( FALSE ) There are two kinds of matlab files (M-files): script M-
file and function M-files. One important difference between them is that script M-
file can accept input parameters while function M-file can not. (2 pts)

It is FALSE. The correct statement is: “function M-file can accept input
parameters while script M-file can not.

3. What is the output of this program: (2 pts)

k = 0;
for i = 1:2:10
k = 2*i + 5
end

7, 11, 15, 19, 23
CSE 150 MatLab                                                         Spring 2005
Lab 2/21/2005                                                               Quiz 1
4. The following matlab command, myFile = fopen(‘mydata.dat’. ‘w’)
accomplishes which of the following: (2 pts)
a).    Opens the file named “myFile” for write.
b)     Opens the file named “myData.dat” for write
c)     Opens the file named “myFile” for read.
d)     Opens the file named “myData.dat” for read.
e)     none of the above

5. There are several array functions. What is the difference between the following
two functions (suppose A is an array): (2 pts)
(1) max(A)
(2) [x, k] = max(A)

(1) Return the max value in array A.
(2) The max value in array A is store in x. The index of x in array A is stored in k.
CSE 150 MatLab                                                         Spring 2005
Lab 2/21/2005                                                               Quiz 1

Part 2: Programming (15 pts)

1. Look at problem 16 on page 180 of your text book. Do part (a) only.
(Name the function file as “torus.m” and electronically submit it. (4pts)

Look at the program “torus.m” on the course web site.

2. Solve problem 39 on page 67 of your text book. Name the file “series.m” and
electronically submit it. (3pts)

Look at the program “series.m” on the course web site.

3. Look at problem 28 on page 65 of your text book. Write a function file called
‘fenceDem.m’ that will take as input a data file called ‘plotDems.txt’ and output
each ‘L’ to a text file called ‘LDem.txt ‘. The following data should be typed into
this text file, separating the two numbers per line with a tab. Since precise file
and function names have been given for these exercises, they should be used.
This is part of a program specification. (8pts)

W         A
8      96
6     117
12     156
10     265
24     960
50    5625

Electronically submit all three files through webhandin.

Look at the three files on the course web site.

Suppose you save the files in the folder “Matlab-examples” in your Z: disk, then
run the following command to execute the program:

fenceDem('plotDEms.txt', 'Z:\Matlab-examples\LDem.txt')

A sample output (LDem.txt) is put on the course web too.

```
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
 views: 0 posted: 2/13/2013 language: Unknown pages: 3
How are you planning on using Docstoc?