You are on page 1of 2

CS 113 Lab 03

Spring 2015-16
Lab 2

Important:
For each question, open a new script (.m file) and name it
YourLastname_firstname_Lab01_QuestionNumber.m (ex: akgun_ali_Lab01_q1b.m )

Do not use Turkish characters in file names.

At the end of the lab zip your m-files with YourLastName_Name_Lab01.zip


(ex: akgun_ali_Lab01.zip ) and upload.

You must show your work at the end of the lab to your TA to get your grade.

Hints:
Dont forget to include the commands: clear; clc; at beginning of your scripts to clear
command and variable windows.

MATLAB has a rich help database. Use it as much as possible.

Question 1 (30 points)


Create a 4*5 matrix with the following properties, and you should use rand function which
returns a number between [0,1].
a)
- 1st row of the matrix will be between [21, 38]
- 2nd row will be between [13, 45]
- 3rd row will be between [9, 33]
- 4th row will be between [16, 57]
b)
You will provide a vector including the variance of each column. Variance formulation is as
follows:

Here represents the items in the columns and is the average of the respective column
of and n is the number of elements in vector x.

Question 2 (20 points)

a) Check whether the above linear equations system have a unique solution.
b) Find the value of each variable using 2 different methods and display the solution as In
the solution x=... y=... z=....

Question 3 (30 points)


Define A, B and C as the vectors A has 3 equally spaced numbers between 1 and 1.33 ,
B has numbers between 2.65 and 7 with 1.78 space, and C = 9, 6, 3.
a) Write a script to merge A, B, C to create a 3*3 matrix where transpose of A, B, and C
are placed in each column of matrix Z.
b) Then create a new vector D which includes minimum number of each column and print
the vector with the format having 1 decimal point as new vector is [d1 d2 d3].
Question 4 (20 points)
The prices of different items in different stores as follows:
Market1: 5, 6, 78, 34, 12, 32
Market2: 4, 7, 82, 31, 10, 33
Market3: 6, 4, 91, 31, 8, 30
Create corresponding three vectors named M1, M2, and M3 which have length of 6. By
using these vectors, answer the following questions:
a) Determine how many items in Market1 is cheaper than Market2.
b) Determine how many items in Market2 has the same price as in Market3.
c) Determine how many items in Market1 is more expensive than Market3.

You might also like