Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
20 views

Matlab

The document provides examples of using MATLAB to perform basic arithmetic operations and matrix manipulations. It demonstrates commands like defining matrices, performing element-wise operations, taking sums, transposing matrices, indexing into matrices, and removing elements from matrices.

Uploaded by

felariesyha
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Matlab

The document provides examples of using MATLAB to perform basic arithmetic operations and matrix manipulations. It demonstrates commands like defining matrices, performing element-wise operations, taking sums, transposing matrices, indexing into matrices, and removing elements from matrices.

Uploaded by

felariesyha
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

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

Warning: Unable to register DirectX component C:\MATLAB701\toolbox\matlab\audiovideo\private\


MatlabDataSink.dll

Warning: Unable to register DirectX component C:\MATLAB701\toolbox\matlab\audiovideo\private\


MatlabDataSource.dll

>> A=10

A=

10

>> 2*10

ans =

20

>> A^2

ans =

100

>> A= [10 2 3 ; 3 2 1; 1 2 3]

A=

10 2 3

3 2 1

1 2 3
>> B=A'

B=

10 3 1

2 2 2

3 1 3

>> C=[A [4 1 4]']

C=

10 2 3 4

3 2 1 1

1 2 3 4

>> A= [10 2 3 ; 3 2 1; 1 2 3]

A=

10 2 3

3 2 1

1 2 3

>> A=[1:4 10:12 ; 3:6 11:13 ; 4:6 12:15]

A=

1 2 3 4 10 11 12

3 4 5 6 11 12 13

4 5 6 12 13 14 15
>> B=1000 + [1:6 ; 500 + [0:10:50]]

B=

1001 1002 1003 1004 1005 1006

1500 1510 1520 1530 1540 1550

>> sum(1:10)

ans =

55

>> sum(1:100)

ans =

5050

>> sum(1:2:100)

ans =

2500

>> sum(2:2100)

ans =

2206049
>> sum(2:2:100)

ans =

2550

>> length(5:5:100)

ans =

20

>> sum(1:2:1000/length(1:2:1000)

??? sum(1:2:1000/length(1:2:1000)

Error: Incomplete or misformed expression or statement.

>> sum(1:2:1000)/length(1:2:1000)

ans =

500

>> a=

??? a=

Error: Incomplete or misformed expression or statement.

>> a

??? Undefined function or variable 'a'.


>> A =

??? A =

Error: Incomplete or misformed expression or statement.

>> A=

??? A=

Error: Incomplete or misformed expression or statement.

>> a =

??? a =

Error: Incomplete or misformed expression or statement.

>> A

A=

1 2 3 4 10 11 12

3 4 5 6 11 12 13

4 5 6 12 13 14 15

>> B=A(2,[3 4])

B=

5 6

>> B=A ([1 3],[2:6])


B=

2 3 4 10 11

5 6 12 13 14

>> A(:,4)=[]

A=

1 2 3 10 11 12

3 4 5 11 12 13

4 5 6 13 14 15

>> C=sum(A)

C=

8 11 14 34 37 40

>> D=(sum(A))

D=

8 11 14 34 37 40

>> D=sum(sum(A))

D=

144
>> sum(1./(2:100))

ans =

4.1874

>> sum((1:2:9)/(2:3:4))

ans =

12.5000

>> sum((1:2:9)./(2:3:4))

ans =

12.5000

>> sum((1:2:9)./(2:3:14))

ans =

3.0042

>> ((1:2:9)./(2:3:14))

ans =

0.5000 0.6000 0.6250 0.6364 0.6429


>> (-1).^(1:3)

ans =

-1 1 -1

>> (-1).^(1:3).*[2:4]

ans =

-2 3 -4

>> sum ((-1).^(1:3).*[2:4])

ans =

-3

>> 1+sum(2:2:90)-sum(3:2:91)

ans =

-44

>> 1+sum((-1),^(1:90).*(2:91))

??? 1+sum((-1),^(1:90).*(2:91))

Error: Missing variable or function.

>> 1+sum((-1).^(1:90).*(2:91))
ans =

46

>> 1+sum(-(-1).^length(2.91).*(2:91))

ans =

4186

>>

You might also like