matlab


>> log(10)

ans =

2.3026

>> b=sin(pi/2)

b =

1

>> c=[1 2 3]

c =

1 2 3

>> d=[1 2;3 4;5 6]

d =

1 2
3 4
5 6

>> d(1,2)

ans =

2

>> d(2,:)

ans =

3 4

>> d(1:2,:)

ans =

1 2
3 4

>> d[1 3]
d[1 3]
|
Error: Unbalanced or unexpected parenthesis
or bracket.

>> d[1 3,:]
d[1 3,:]
|
Error: Unbalanced or unexpected parenthesis
or bracket.

>> d([1 3],:)

ans =

1 2
5 6

>> d(end, end)

ans =

6

>> e=1:10

e =

Columns 1 through 7

1 2 3 4 5 6 7

Columns 8 through 10

8 9 10

>> f=-5:2:5

f =

-5 -3 -1 1 3 5

>> f(1)

ans =

-5

>> size(d)

ans =

3 2

>> size(d,2)

ans =

2

>> length(c)

ans =

3

>> s='Matlab'

s =

Matlab

>> []

ans =

[]

>> []d
[]d
|
Error: Unexpected MATLAB expression.

>> d

d =

1 2
3 4
5 6

>> d[]
d[]
|
Error: Unbalanced or unexpected parenthesis
or bracket.

>> d(1,:)=[]

d =

3 4
5 6

>> A=[B;C]
Undefined function or variable 'B'.

>> A=zeros(3,4)

A =

0 0 0 0
0 0 0 0
0 0 0 0

>> B=ones(4,2)

B =

1 1
1 1
1 1
1 1

>> C=(A;B)
C=(A;B)
|
Error: Unbalanced or unexpected parenthesis
or bracket.

>> A=rand(3,4)

A =

0.8147 0.9134 0.2785 0.9649
0.9058 0.6324 0.5469 0.1576
0.1270 0.0975 0.9575 0.9706

>>
>> A=rand(4)

A =

0.9572 0.4218 0.6557 0.6787
0.4854 0.9157 0.0357 0.7577
0.8003 0.7922 0.8491 0.7431
0.1419 0.9595 0.9340 0.3922

>> A+B
Error using +
Matrix dimensions must agree.

>> B=rand(4,4)

B =

0.6555 0.2769 0.6948 0.4387
0.1712 0.0462 0.3171 0.3816
0.7060 0.0971 0.9502 0.7655
0.0318 0.8235 0.0344 0.7952

>> A+B

ans =

1.6126 0.6987 1.3506 1.1175
0.6566 0.9619 0.3528 1.1393
1.5063 0.8893 1.7994 1.5086
0.1737 1.7830 0.9684 1.1874

>> A*B

ans =

1.1842 0.9071 1.4453 1.6226
0.5242 0.8041 0.6877 1.1923
1.2834 0.9526 1.6397 1.8944
0.9292 0.4973 1.3039 1.4552

zadanie 2
>> A=[1,2,4,1;0,4,6,4;5,4,2,4;12,3,2,7]

A =

1 2 4 1
0 4 6 4
5 4 2 4
12 3 2 7

>> B=[5,8,4,3;9,5,1,3;0,5,2,3;1,2,5,3]

B =

5 8 4 3
9 5 1 3
0 5 2 3
1 2 5 3

zadanie 3

>> A+B

ans =

6 10 8 4
9 9 7 7
5 9 4 7
13 5 7 10

>> A-B

ans =

-4 -6 0 -2
-9 -1 5 1
5 -1 0 1
11 1 -3 4

>> A*B

ans =

24 40 19 24
40 58 36 42
65 78 48 45
94 135 90 72

>> A.*B

ans =

5 16 16 3
0 20 6 12
0 20 4 12
12 6 10 21

>> A/B

ans =

0.6688 -0.3224 -0.5708 0.5577
0.1002 -0.1656 0.4096 0.9891
-0.5076 0.7952 0.6645 0.3813
-1.8214 2.2266 0.8606 1.0675

>> A./B

ans =

0.2000 0.2500 1.0000 0.3333
0 0.8000 6.0000 1.3333
Inf 0.8000 1.0000 1.3333
12.0000 1.5000 0.4000 2.3333

>> A\B

ans =

-0.3986 1.1329 1.0420 0.3776
-1.2308 2.0769 0.0769 0.6923
1.7517 1.4161 1.0524 0.4720
0.8531 -2.9510 -1.4056 -0.6503

>> A.\B

ans =

5.0000 4.0000 1.0000 3.0000
Inf 1.2500 0.1667 0.7500
0 1.2500 1.0000 0.7500
0.0833 0.6667 2.5000 0.4286

>> A^2

ans =

33 29 26 32
78 52 44 68
63 46 56 57
106 65 84 81


>> A.^B

ans =

1 256 256 1
0 1024 6 64
1 1024 4 64
12 9 32 343

>> A'

ans =

1 0 5 12
2 4 4 3
4 6 2 2
1 4 4 7

>> A.'

ans =

1 0 5 12
2 4 4 3
4 6 2 2
1 4 4 7

zadanie 4
>> x=A(1,:)

x =

1 2 4 1

>> y=[B(:,[2:3])]

y =

8 4
5 1
5 2
2 5

>> (3*x)*(5*y)

ans =

600 285

>> (((4*x')*x).^2)*(2*y)

ans =

3520 1440
14080 5760
56320 23040
3520 1440

>> (((4*x')*x)^2)*(2*y)

ans =

28160 13376
56320 26752
112640 53504
28160 13376


>> q([1:2],:)=z

q =

4.8584 1.8584 1.8584 -1.1416
0.8584 -2.1416 -1.1416 1.8584

>> q([3:4],:)=y'

q =

4.8584 1.8584 1.8584 -1.1416
0.8584 -2.1416 -1.1416 1.8584
8.0000 5.0000 5.0000 2.0000
4.0000 1.0000 2.0000 5.0000



Wyszukiwarka

Podobne podstrony:
MATLAB cw Skrypty
SIMULINK MATLAB to VHDL Route
IMiR NM2 Introduction to MATLAB
matlab skrypty
MATLAB2
statystyka w matlabie
Matlab Kosinska
Slowniczek matlab
pn10 Matlab lab3 Bubak
MATLAB INFORMACJE
MATLAB cw Skorowidz hasel
Cw1 Matlab
W01 Matlab1
wprowadzenie Matlab Simulink
Projektowanie regulatorów rozmytych w środowisku Matlab Simulink
matlab podstawy programowania

więcej podobnych podstron