Вы находитесь на странице: 1из 10

To get started, select MATLAB Help or Demos from the Help menu.

>> a(5:10)=[10 15 20 25 30 35]

a=

0 0 0 0 10 15 20 25 30 35

>> a=[1 2 3 4]

a=

1 2 3 4

>> a(5:10)=[10 15 20 25 30 35]

a=

1 2 3 4 10 15 20 25 30 35

>> b=[1 2 3]

b=

1 2 3

>> b(7:8)=[4 5]

b=

1 2 3 0 0 0 4 5

>> A=[1 2 3 4],B=[4:3:16]

A=

1 2 3 4

B=

4 7 10 13 16

>> C=[A B]
C=

1 2 3 4 4 7 10 13 16

>> D=[A';B']

D=

1
2
3
4
4
7
10
13
16

>> X=[1 2 3 4; 5 6 7 8]

X=

1 2 3 4
5 6 7 8

>> x(3: )=[10:4:22]


??? x(3: )=[10:4:22]
|
Error: Unbalanced or misused parentheses or brackets.

>> x(3,:)=[10:4:22]

x=

0 0 0 0
0 0 0 0
10 14 18 22

>> X(3,:)=[10:4:22]

X=

1 2 3 4
5 6 7 8
10 14 18 22
>> X(3)=[10:4:22]
??? In an assignment A(I) = B, the number of elements in B and
I must be the same.

>> X(3,s)=[10:4:22]
??? Undefined function or variable 's'.

>> X(3,3)=[10:4:22]
??? Subscripted assignment dimension mismatch.

>> X(3,:3)=[10:4:22]
??? X(3,:3)=[10:4:22]
|
Error: Missing MATLAB operator.

>> X(3,:1)=[10:4:22]
??? X(3,:1)=[10:4:22]
|
Error: Missing MATLAB operator.

>> X(3,:)=[10:4:22]

X=

1 2 3 4
5 6 7 8
10 14 18 22

>> i=eye(3,3)

i=

1 0 0
0 1 0
0 0 1

>> Y=[X,i]

Y=

1 2 3 4 1 0 0
5 6 7 8 0 1 0
10 14 18 22 0 0 1

>> s(10)=[1 2 3 4 5 6 7 8 9 1]
??? In an assignment A(I) = B, the number of elements in B and
I must be the same.

>> s=[1 2 3 4 5 6 7 8 9 1]

s=

1 2 3 4 5 6 7 8 9 1

>> s(6)=[ ]

s=

1 2 3 4 5 7 8 9 1

>> s(3:6)=[ ]

s=

1 2 8 9 1

>> v(3:5)
??? Undefined command/function 'v'.

>> v(3,:5)
??? v(3,:5)
|
Error: Missing MATLAB operator.

>> v=[1 2 3 4 5;
2 3 4 5 6;
4 5 6 7 8]

v=

1 2 3 4 5
2 3 4 5 6
4 5 6 7 8

>> v(3,:5)=[1 2 32 4 4 5 5 6 71 1 1 1 1 1 1 1]
??? v(3,:5)=[1 2 32 4 4 5 5 6 71 1 1 1 1 1 1 1]
|
Error: Missing MATLAB operator.

>> v( ,:(2:4)=[]
??? v( ,:(2:4)=[]
|
Error: Incomplete or misformed expression or statement.

>> v( ,:(2:4))=[]
??? v( ,:(2:4))=[]
|
Error: Incomplete or misformed expression or statement.

>> v(,:(2:4))=[]
??? v(,:(2:4))=[]
|
Error: Incomplete or misformed expression or statement.

>> v(,(2:4))=[]
??? v(,(2:4))=[]
|
Error: Incomplete or misformed expression or statement.

>> v(:(2:4))=[]
??? v(:(2:4))=[]
|
Error: Unbalanced or misused parentheses or brackets.

>> v(3,(2:4))=[]
??? Indexed empty matrix assignment is not allowed.

>> v(3,(2:4))=[ ]
??? Indexed empty matrix assignment is not allowed.

>> v(3,:(2:4))=[ ]
??? v(3,:(2:4))=[ ]
|
Error: Unbalanced or misused parentheses or brackets.

>> v(3,2:4)=[ ]
??? Indexed empty matrix assignment is not allowed.

>> v(:2:4)=[ ]
??? v(:2:4)=[ ]
|
Error: Missing MATLAB operator.

>> v(:,2:4)=[ ]

v=

1 5
2 6
4 8

>> size(v)

ans =

3 2

>> length(s)

ans =

>> reshape(v,3,3)
??? Error using ==> reshape
To RESHAPE the number of elements must not change.

>> reshape(v,4,4)
??? Error using ==> reshape
To RESHAPE the number of elements must not change.

>> Reshape(v,4,4)
??? Undefined command/function 'Reshape'.

>> reshape(v,2,3)

ans =

1 4 6
2 5 8

>> n=7 4 2]
??? n=7 4 2]
|
Error: Missing MATLAB operator.

>> n=[7 4 2]

n=

7 4 2

>> w=diag[n]
??? w=diag[n]
|
Error: Unbalanced or misused parentheses or brackets.

>> w=diag
(n)
??? Error using ==> diag
Not enough input arguments.

Error in ==> diag at 29


[varargout{1:nargout}] = builtin('diag', varargin{:});

>> w=[1 2 3;2 3 4;3 4 5]

w=

1 2 3
2 3 4
3 4 5

>> b=[7 4 2]

b=

7 4 2

>> w=diag(b)

w=

7 0 0
0 4 0
0 0 2

>> u=[1 2 3;2 3 4;3 4 5]

u=

1 2 3
2 3 4
3 4 5

>> l=diag(u)

l=

1
3
5

>> u=[1 2 3;4 5 6;7 8 9]

u=

1 2 3
4 5 6
7 8 9

>> l=diag(u)

l=

1
5
9

>> c=[2 4 6 8 10;3 6 9 12 15;7 14 21 28 35]

c=

2 4 6 8 10
3 6 9 12 15
7 14 21 28 35

>> ua=c[:,3]
??? ua=c[:,3]
|
Error: Unbalanced or misused parentheses or brackets.

>> ua=c(:,3)

ua =

6
9
21

>> ub=c(2,:)

ub =

3 6 9 12 15
>> uc=c(:,1:3:5)

uc =

2 8
3 12
7 28

>> uc=c(:,1;3;5)
??? uc=c(:,1;3;5)
|
Error: Incomplete or misformed expression or statement.

>> uc=c(:,1,3,5)
??? Index exceeds matrix dimensions.

>> uc=c(:,(1,3,5))
??? uc=c(:,(1,3,5))
|
Error: Incomplete or misformed expression or statement.

>> uc=c(:,(1;3;5))
??? uc=c(:,(1;3;5))
|
Error: Incomplete or misformed expression or statement.

>> uc=c(:,(1:3:5))

uc =

2 8
3 12
7 28

>> uc=c(:,[1,3,5])

uc =

2 6 10
3 9 15
7 21 35

>> ud=c([1,2]:,)
??? ud=c([1,2]:,)
|
Error: Incomplete or misformed expression or statement.
>> ud=c([1,2],:)

ud =

2 4 6 8 10
3 6 9 12 15

>> b=[7 4 2]

Вам также может понравиться