Contents

Problem 1:

given:

A = [ 34 56 31; -45 6 43 ]
A =

    34    56    31
   -45     6    43

compute:

size(A)
A.^2
% demonstrates component-wise squaring
ans =

     2     3


ans =

        1156        3136         961
        2025          36        1849

Problem 2:

given:

abc = 1:10
def = 5:14
abc =

     1     2     3     4     5     6     7     8     9    10


def =

     5     6     7     8     9    10    11    12    13    14

compute:

ghi = 3*abc + def + 1
% demonstrates scalar mult and addition
ghi =

     9    13    17    21    25    29    33    37    41    45

Problem 3:

given:

abc = [1 2 3 4;5 6 7 8]
def = [4 3 2 1;0 -1 -3 3]
abc =

     1     2     3     4
     5     6     7     8


def =

     4     3     2     1
     0    -1    -3     3

compute:

%abc*def
abc*def'
abc'*def
abc.*def
% demonstrates the correct way(s) to multiply matrices
ans =

    20     1
    60    -3


ans =

     4    -2   -13    16
     8     0   -14    20
    12     2   -15    24
    16     4   -16    28


ans =

     4     6     6     4
     0    -6   -21    24

Problem 4:

given

f='x+cos(x)^2'
f =

x+cos(x)^2

compute the integral

I=int(f)
 
I =
 
x/2 + sin(2*x)/4 + x^2/2
 

compute the integral and display as if typeset:

pretty((int(f)))
% note that this requires the symbolic toolbox to be installed
                  2
  x   sin(2 x)   x
  - + -------- + --
  2      4       2

plot the integral on [-2 pi 2 pi]

ezplot(I,[-2*pi 2*pi])