Sei sulla pagina 1di 12

>> year=[1984 1986 1988 1990 1992 1994 1996]

year =

1984 1986 1988 1990 1992 1994 1996

>> population=[ 127 130 136 145 158 178 211]

population =

127 130 136 145 158 178 211

>> year'

ans =

1984

1986

1988

1990

1992

1994

1996

>> population'

ans =

127
130

136

145

158

178

211

>> %%constant spacing

>> ytrans=year'

ytrans =

1984

1986

1988

1990

1992

1994

1996

>> ptrans=population'

ptrans =

127

130

136

145

158
178

211

>> %%array

>> year=1984:1990:1996

year =

1984

>> year=year=1984:2:1996

year=year=1984:2:1996

Error: The expression to the left of the equals sign is not a valid target for an assignment.

Did you mean:

>> year = 1984:2:1996

year =

1984 1986 1988 1990 1992 1994 1996

>> min(min(population))

ans =

127

>>
>>

>>

>> population=[ 127e6 130e6 136e6 145e6 158e6 178e6 211e6]

population =

127000000 130000000 136000000 145000000 158000000 178000000 211000000

>> min(min(population))

ans =

127000000

>> max(max(population))

ans =

211000000

>> mean(mean(population))

ans =

155000000

>> sum(sum(population))

ans =
1.0850e+09

>> %%problem 2

>> A=[5 2 1;1 7 -3;6 -10 2/3]

A=

5.0000 2.0000 1.0000

1.0000 7.0000 -3.0000

6.0000 -10.0000 0.6667

>> B=[11 5 3;2 6.54 1]

B=

11.0000 5.0000 3.0000

2.0000 6.5400 1.0000

>> C=[7 14 1;10 3 -2;8 -5 9]

C=

7 14 1

10 3 -2

8 -5 9

>> A+C
ans =

12.0000 16.0000 2.0000

11.0000 10.0000 -5.0000

14.0000 -15.0000 9.6667

>> C-A

ans =

2.0000 12.0000 0

9.0000 -4.0000 1.0000

2.0000 5.0000 8.3333

>> A*B

Error using *

Inner matrix dimensions must agree.

>> B*A

ans =

78.0000 27.0000 -2.0000

22.5400 39.7800 -16.9533

>> 3.2*(A+C)

ans =
38.4000 51.2000 6.4000

35.2000 32.0000 -16.0000

44.8000 -48.0000 30.9333

>> 3.2*A+3.2*C

ans =

38.4000 51.2000 6.4000

35.2000 32.0000 -16.0000

44.8000 -48.0000 30.9333

>> A*B

Error using *

Inner matrix dimensions must agree.

>> A-B

Matrix dimensions must agree.

>> A+B

Matrix dimensions must agree.

>>

>> eye(size(A))

ans =

1 0 0

0 1 0
0 0 1

>> eye(size(A))+A

ans =

6.0000 2.0000 1.0000

1.0000 8.0000 -3.0000

6.0000 -10.0000 1.6667

>> magic(2)+C

Matrix dimensions must agree.

>> magic(3)*C

ans =

114 85 60

127 22 56

134 73 4

>> A

A=

5.0000 2.0000 1.0000

1.0000 7.0000 -3.0000

6.0000 -10.0000 0.6667


>> C

C=

7 14 1

10 3 -2

8 -5 9

>> A=[5 2 1;1 7 -3;6 -10 2/3]

A=

5.0000 2.0000 1.0000

1.0000 7.0000 -3.0000

6.0000 -10.0000 0.6667

>> A

A=

5.0000 2.0000 1.0000

1.0000 7.0000 -3.0000

6.0000 -10.0000 0.6667

>> A*/C

A*/C

Error: Unexpected MATLAB operator.


>> A./C

ans =

0.7143 0.1429 1.0000

0.1000 2.3333 1.5000

0.7500 2.0000 0.0741

>> A.*C

ans =

35 28 1

10 21 6

48 50 6

>> A.^C

ans =

1.0e+06 *

0.0781 0.0164 0.0000

0.0000 0.0003 0.0000

1.6796 -0.0000 0.0000

>> 5^7

ans =
78125

>> magic(size(C))*C

ans =

114 85 60

127 22 56

134 73 4

>>