>> A=[1 3;2 8]

A =

     1     3

     2     8

>> size(A)

ans =

     2     2

>> V=input('enter matrix')

enter matrix[4 5 6;1 8 2]

V =

     4     5     6

     1     8     2

>> c=ones(4,2)

c =

     1     1

     1     1

     1     1

     1     1

>> D=eye(3)

D =

     1     0     0

     0     1     0

     0     0     1

>> E=zeros(3,4)

E =

     0     0     0     0

     0     0     0     0

     0     0     0     0

>> X=rand(2,3)

X =

    0.9501    0.6068    0.8913

    0.2311    0.4860    0.7621

>> B=[1 3 5 4 1;2 4 7 3 2]

B =

     1     3     5     4     1

     2     4     7     3     2

>> mean(B)

ans =

    1.5000    3.5000    6.0000    3.5000    1.5000

>> C=B'

C =

     1     2

     3     4

     5     7

     4     3

     1     2 

>> mean(C)

ans =

    2.8000    3.6000

>> sum(C(:,2))

ans =

    18

>> sum(C([2:4],:))

ans =

    12    14

>> %adds the number of males from .2 to .8, and the number of females between .2 and .8

>> D=rand(3,4)

D =

    0.4565    0.4447    0.9218    0.4057

    0.0185    0.6154    0.7382    0.9355

    0.8214    0.7919    0.1763    0.9169

>> P=[10;15;20;10]

P =

    10

    15

    20

    10

>> D*P

ans =

   33.7285

   33.5354

   32.7875

>> %took a 3 row by 4 column matrix and multiplied by a vector column to get delays from weather, plane problems, and traffic

>> P2=[10 20; 15 0; 20 30; 10 10]

P2 =

    10    20

    15     0

    20    30

    10    10

>> D*P2

ans =

   33.7285   40.8408

   33.5354   31.8710

   32.7875   30.8852

>> %gives the delays in the first month and the delays in the second month

>> %in matrix multiplication, the number of rows in the second matrix must equal the number of columns in the first matrix

>> A=[2 5 4 3 7];

>> sumo=0 

sumo =

     0

>> for ii = [1:5]

sumo=sumo+A(ii)

end

sumo =

     2

sumo =

     7

sumo =

    11

sumo =

    14

sumo =

    21

>> %repeats the process of addition from the first to the fifth number (eg. first+sumo=2, second+sumo=7)

>> x=input('enter the number you are looking for')

enter the number you are looking for5

x =

     5

>> for ii=[1:5]

if A(ii)==x

fprintf('I found %f at index %f',x,ii)

end

end

I found 5.000000 at index 2.000000>>

>> %searches for the x value within the set of numbers until it finds it

>> for n=[1:10]

fprintf('%f\n',1/n)

end

1.000000

0.500000

0.333333

0.250000

0.200000

0.166667

0.142857

0.125000

0.111111

0.100000