A = [1,2;3,4]
A =
1 2
3 4
C = A * inv(A)
C =
1.0000 0
0.0000 1.0000
format long
C
C =
1.000000000000000 0
0.000000000000001 1.000000000000000
C(2,1)
ans =
8.881784197001252e-16
2 / 3
ans =
0.666666666666667
3 \ 2
ans =
0.666666666666667
clear all
clc
a = [1, 2, 3, 4, 5]
a =
1 2 3 4 5
b = a(end:-1:1)
b =
5 4 3 2 1
a * b
{Error using *
Inner matrix dimensions must agree.
}
size(a)
ans =
1 5
size(b)
ans =
1 5
rozmer_becka = size(b)
rozmer_becka =
1 5
rozmer_becka(1)
ans =
1
rozmer_becka(2)
ans =
5
a * b
{Error using *
Inner matrix dimensions must agree.
}
b * a
{Error using *
Inner matrix dimensions must agree.
}
a
a =
1 2 3 4 5
b
b =
5 4 3 2 1
a.'
ans =
1
2
3
4
5
a
a =
1 2 3 4 5
c = a.'
c =
1
2
3
4
5
d = b.'
d =
5
4
3
2
1
a
a =
1 2 3 4 5
b
b =
5 4 3 2 1
c
c =
1
2
3
4
5
d
d =
5
4
3
2
1
a.'
ans =
1
2
3
4
5
a
a =
1 2 3 4 5
a
a =
1 2 3 4 5
d
d =
5
4
3
2
1
a * d
ans =
35
d * a
ans =
5 10 15 20 25
4 8 12 16 20
3 6 9 12 15
2 4 6 8 10
1 2 3 4 5
d
d =
5
4
3
2
1
a
a =
1 2 3 4 5
a
a =
1 2 3 4 5
d
d =
5
4
3
2
1
a .* b
ans =
5 8 9 8 5
a .* d
ans =
5 10 15 20 25
4 8 12 16 20
3 6 9 12 15
2 4 6 8 10
1 2 3 4 5
a
a =
1 2 3 4 5
d
d =
5
4
3
2
1
a
a =
1 2 3 4 5
b
b =
5 4 3 2 1
x = [10, 20]
x =
10 20
y = [34, 55]
y =
34 55
x
x =
10 20
y
y =
34 55
cross(x,y)
{Error using cross (line 25)
A and B must be of length 3 in the dimension in which the cross product is
taken.
}
x = [x, 44]
x =
10 20 44
y = [y, 12]
y =
34 55 12
x
x =
10 20 44
y
y =
34 55 12
cross(x,y)
ans =
-2180 1376 -130
dot(x,y)
ans =
1968
blap = [1,2,4,7,...
34,67,44]
blap =
1 2 4 7 34 67 44
clear all
clc
A=[10,5,70,5,5;2,7,6,9,6;8,9,1,45,22;...
3,12,6,8,33; 20, 2,20,96,98];
b=[275;100;319;242;958];
x = A \ b
x =
0.999999999999994
2.000000000000001
3.000000000000000
4.000000000000001
5.000000000000000
format short
x
x =
1.0000
2.0000
3.0000
4.0000
5.0000
A=rand(1000);
b = rand(1000,1);
x = A \ b;
A=[10,5,70,5,5;2,7,6,9,6;8,9,1,45,22;...
3,12,6,8,33; 20, 2,20,96,98];
b=[275;100;319;242;958];
x = A \ b;
x
x =
1.0000
2.0000
3.0000
4.0000
5.0000
inv(A)
ans =
0.1862 -2.0139 0.8145 0.5274 -0.2466
-0.0012 0.0464 0.0318 0.0366 -0.0222
-0.0096 0.2584 -0.1081 -0.0711 0.0329
-0.0289 0.3230 -0.1070 -0.1029 0.0404
-0.0077 0.0409 -0.0400 0.0069 0.0147
round(inv(A))
ans =
0 -2 1 1 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
x = round(inv(A).*1000)./1000 * b
x =
0.3240
2.4110
3.0300
3.5860
5.2040
round(inv(A).*1000)./1000
ans =
0.1860 -2.0140 0.8140 0.5270 -0.2470
-0.0010 0.0460 0.0320 0.0370 -0.0220
-0.0100 0.2580 -0.1080 -0.0710 0.0330
-0.0290 0.3230 -0.1070 -0.1030 0.0400
-0.0080 0.0410 -0.0400 0.0070 0.0150