Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

MatLab- Exercise set n.

1
Matrices, Script, functions and graphs
1) Consider the given matrix with size 4 x 6

4 3 1 2 5 4
0 1 1 3 6 2
4 4 5 1 1 1
2 1 3 1 5 6

Assign the Matrix with name A in Matlab.


Write a Script to code the following requests:
1. Obtain the transpose matrix
2. Select the sub-matrices represented in colors: matrix B the one in Yellow, C in Cyan
3. Compute the determinant of B, and the product matrix of B and C (if possibile)
4. Compute the inverse of B (if possible)
5. Compute the sum of elements in each row and columns.
6. Compute the min and max of elements in each row and columns.
7. Compute the sum, min and max of the whole matrix.
8. Rappresent graphically all colums as horizontal bar gaphs; similarly, represent rows as bar
graphs.

Save the script as Ex1.1Last name.m

2) Consider the following functions in their natural domain:

a) f(x)=x2+4x-3

b) h(x)=exp(f(x)/100)-2;

c) g(x1,x2)=x12+x22+32-4x2+24x1x2

Write corresponding Matlab functions both “inline” and through a file namefunction.m

Represents the three functions graphically.

Save the script as Ex1.2Last name.m


3) Obtain from yahoo finance daily data for one equity or market index of your choice.
(with n > 100 number of observations).

Import data in Matlab and write a script to code the following requests:

1. Compute daily logarithimc returns


2. Represent prices graphically with a dashed red line (single figure).
3. Represent logarithmic returns graphically with a solid black line (single figure).
4. Obtain the percentage of positive and negative logreturns.
5. Use a pie chart to represent graphically the above result.
6. Include the above picture in the same figure.

Save the script as Ex1.3Lastname.m

Save the workspace as Ex1Lastname.mat

You might also like