Sie sind auf Seite 1von 7

This is a Classroom License for instructional use only.

Research and commercial use is prohibited.


To get started, select "MATLAB Help" from the Help menu.
>> cd c:\gego
??? Name is nonexistent or not a directory
>> cd d:\gego
>> 3p1
??? 3p1
|
Error: Missing operator, comma, or semicolon.
>> 3p1.m
??? 3p1.m
|
Error: Missing operator, comma, or semicolon.
>> x=lerfhm(A,b)
??? Undefined function or variable 'A'.
>> A=[1,2,3,0,1,-1,0,0,2]
A =
1

-1

>> b=[13,-1,6]
b =
13

-1

>> x=lerfhm(A,b)
??? Undefined function or variable 'lerfhm'.
>> clear A
>> clear b
>> A
??? Undefined function or variable 'A'.
>> b
??? Undefined function or variable 'b'.
>> A=[1,2,3,0,1,-1,0,0,2]
A =
1

-1

>> b=[13,-1,6]
b =
13

-1

>> cd d:\gego
>> x=lerfhm(A,b)
??? Undefined function or variable 'lerfhm'.

>> x=lerfhm(3,4)
??? Undefined function or variable 'lerfhm'.
>> x=lerfhm(A,b)
??? Undefined function or variable 'lerfhm'.
>> A
A =
1

13

-1

-1

>> b
b =

>> x=lerfhm(A,b)
??? Undefined function or variable 'lerfhm'.
>> x=lerfhm(A,b)
??? Index exceeds matrix dimensions.
Error in ==> D:\gego\lerfhm.m
On line 10 ==> x(n)=b(n)/A(n,n);
>> A
A =
1

-1

>> clear A
>> A=[1,2,3
0,1,-1
0,0,2]
A =
1
0
0

2
1
0

3
-1
2

>> x=lerfhm(A,b)
??? In an assignment A(I) = B, the number of elements in B and
I must be the same.
Error in ==> D:\gego\lerfhm.m
On line 12 ==>
x(i)=(b(i)-A(i,i+i+1:n)*x(i+i:n)/A(i,i));
>> b
b =
13

-1

>> clear b
>> b=[13;-1;6]

b =
13
-1
6
>> x=lerfhm(A,b)
??? In an assignment A(I) = B, the number of elements in B and
I must be the same.
Error in ==> D:\gego\lerfhm.m
On line 12 ==>
x(i)=(b(i)-A(i,i+i+1:n)*x(i+i:n)/A(i,i));
>> x=lerfhm(A,b)
??? In an assignment A(I) = B, the number of elements in B and
I must be the same.
Error in ==> D:\gego\lerfhm.m
On line 12 ==>
x(i)=(b(i)-A(i,i+i+1:n)*x(i+i:n)/A(i,i));
>> A
A =
1
0
0

2
1
0

3
-1
2

>> b
b =
13
-1
6
>> x=lerfhm(A,b)
??? In an assignment A(I) = B, the number of elements in B and
I must be the same.
Error in ==> D:\gego\lerfhm.m
On line 12 ==>
x(i)=(b(i)-A(i,i+i+1:n)*x(i+i:n)/A(i,i));
>> x=lerfhm(A,b)
??? In an assignment A(I) = B, the number of elements in B and
I must be the same.
Error in ==> D:\gego\lerfhm.m
On line 12 ==>
x(i)=(b(i)-A(i,i+i+1:n)*x(i+i:n)/A(i,i));
>> sgauss
??? Input argument 'A' is undefined.
Error in ==> D:\gego\sgauss.m
On line 5 ==> n=length(A)
>> b
b =

13
-1
6
>> A
A =
1
0
0

2
1
0

3
-1
2

>> A=round(15*rand(n))-5
??? Undefined function or variable 'n'.
>> n=10
n =
10
>> A=round(15*rand(n))-5
A =
9
-2
4
2
8
6
2
-5
7
2

4
7
9
6
-2
1
9
9
1
8

-4
0
7
-5
-3
-2
-2
4
-1
-2

-5
6
2
9
2
1
8
3
-2
5

>> xp=round(10*rand(n,1))-2
xp =
4
2
3
1
2
0
4
6
3
4
>> b=A*xp
b =
96
41
184
76

8
-5
5
1
7
3
6
1
0
-2

-2
5
0
3
-3
5
1
8
8
4

2
8
7
5
7
5
0
-1
0
3

6
0
8
4
1
6
3
2
5
4

7
9
3
8
-2
10
-1
-1
8
6

-3
-5
8
-2
-1
5
-1
2
-4
10

59
133
51
28
63
113
>> x=sgauss(A,b)
n =
10
??? Improper assignment with rectangular empty matrix.
Error in ==> D:\gego\lerfhm.m
On line 12 ==>
x(i)=(b(i)-A(i,i+i+1:n)*x(i+i:n)/A(i,i));
Error in ==> D:\gego\sgauss.m
On line 14 ==> x=lerfhm(A,b);
>> x=sgauss(A,b)
n =
10
x =
-1.057189161864990e+003
-1.684492025834593e+002
-3.103481826521340e+002
-3.341903131886791e+002
7.659871725519741e+002
2.666555840274718e+002
5.711995842254161e+002
3.244362301198623e+002
-7.592111299486284e+001
3.999999999999998e+000
>>
>> A=x-xp
A =
-1.061189161864990e+003
-1.704492025834593e+002
-3.133481826521340e+002
-3.351903131886791e+002
7.639871725519741e+002
2.666555840274718e+002
5.671995842254161e+002
3.184362301198623e+002
-7.892111299486284e+001
-2.220446049250313e-015
>> xm=A\b
xm =

-3.207606970494569e-002
>> xm=A\b % az A inverzevel megszorozzuk a b-t he he he
xm =
-3.207606970494569e-002
>>
>> size(A)
ans =
10

>> % matrix must be square - a matrix nem negyzetes....


>> A
A =
-1.061189161864990e+003
-1.704492025834593e+002
-3.133481826521340e+002
-3.351903131886791e+002
7.639871725519741e+002
2.666555840274718e+002
5.671995842254161e+002
3.184362301198623e+002
-7.892111299486284e+001
-2.220446049250313e-015
>> A=[3,1,2
0,-1,2
0,1,2]
A =
3
0
0

1
-1
1

2
2
2

>> inv2=A^(-1)
inv2 =
3.333333333333333e-001
0
0
>> A
A =
3
0
0

1
-1
1

>> inv3=inv(A)

2
2
2

0
-5.000000000000000e-001
2.500000000000000e-001

-3.333333333333333e-001
5.000000000000000e-001
2.500000000000000e-001

inv3 =
3.333333333333333e-001
0
0
>> D=det(A)
D =
-12
>>

0
-5.000000000000000e-001
2.500000000000000e-001

-3.333333333333333e-001
5.000000000000000e-001
2.500000000000000e-001

Das könnte Ihnen auch gefallen