0% found this document useful (0 votes)
3K views13 pages

B

The document demonstrates how to use MATLAB to perform operations on matrices and vectors including creating, summing, finding maximum and minimum values, and using modulo operators. Various functions like randi, rem, and abs are also shown.

Uploaded by

Jhonny Asp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3K views13 pages

B

The document demonstrates how to use MATLAB to perform operations on matrices and vectors including creating, summing, finding maximum and minimum values, and using modulo operators. Various functions like randi, rem, and abs are also shown.

Uploaded by

Jhonny Asp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

>> b=(0,1,35)

??? b=(0,1,35)

Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.

>> b=(0:1:35)

b=

Columns 1 through 32

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30 31

Columns 33 through 36

32 33 34 35

>> b=(0:1:10)

b=

0 1 2 3 4 5 6 7 8 9 10

>> b=(0 2 3;3 4 5;5 6 7)

??? b=(0 2 3;3 4 5;5 6 7)

Error: Unexpected MATLAB expression.


>> b=[0 2 3;3 4 5;5 6 7]

b=

0 2 3

3 4 5

5 6 7

>> sum(b)

ans =

8 12 15

>> sum(a,2)

??? Undefined function or variable 'a'.

>> sum(b,2)

ans =

12

18

>> sum(sum(b))
ans =

35

>> max(b)

ans =

5 6 7

>> max(max(b))

ans =

>> max(b,2)

ans =

2 2 3

3 4 5

5 6 7

>> max(b,0)
ans =

0 2 3

3 4 5

5 6 7

>> max(b,5)

ans =

5 5 5

5 5 5

5 6 7

>> max(b,6)

ans =

6 6 6

6 6 6

6 6 7

>> max(b,7)

ans =

7 7 7
7 7 7

7 7 7

>> max(b,8)

ans =

8 8 8

8 8 8

8 8 8

>> max(b,4)

ans =

4 4 4

4 4 5

5 6 7

>> max(b,[],2)

ans =

7
>> min(b)

ans =

0 2 3

>> b=[0 2 3;3 4 5;5 6 7]

b=

0 2 3

3 4 5

5 6 7

>> min(b)

ans =

0 2 3

>> min(min(b))

ans =

>> size(suma(suma(b))))
??? size(suma(suma(b))))

Error: Unbalanced or unexpected parenthesis or bracket.

>> c=(1 2 3 4 )

??? c=(1 2 3 4 )

Error: Unexpected MATLAB expression.

>> c=(1 :2 :3 :4 )

c=

1 2 3 4

>> lenght(c)

??? Undefined function or method 'lenght' for input arguments of type 'double'.

>> b=(1:1:10)

b=

1 2 3 4 5 6 7 8 9 10

>> c=b(1:2:lenght(b))

??? Undefined function or method 'lenght' for input arguments of type 'double'.
>> c=b(2:2:lenght(b))

??? Undefined function or method 'lenght' for input arguments of type 'double'.

>> c=b(2:2:length(b))

c=

2 4 6 8 10

>> randi([0 10],3,3)

ans =

8 10 3

9 6 6

1 1 10

>> randi([0 10],-3,3)

ans =

Empty matrix: 0-by-3

>> randi([-10 10],3,3)

ans =
10 10 -8

-7 0 -2

10 6 9

>> x=randi([-10 10],3,3)

x=

6 -10 4

10 7 5

3 9 5

>> sum(sum(a.*c))

??? Undefined function or variable 'a'.

>> sum(sum(a.*x))

??? Undefined function or variable 'a'.

>> sum(sum(a.*x))

??? Undefined function or variable 'a'.

>> sum(sum(x.*(x<0)))

ans =

-10
>> sum(sum(x.*(x>0)))

ans =

49

>> max(sum(x))

ans =

19

>> max(sum(x,2))

ans =

22

>> rem(5,2)

ans =

>> rem(569797,2)

ans =
1

>> y=randi([-10 10],3,3)

y=

-2 4 -10

3 -10 -8

-7 -5 7

>> rem(y,2)

ans =

0 0 0

1 0 0

-1 -1 1

>> length(rem(y,2))

ans =

>> length(rem(y,2)==0)
ans =

>> rem(y,2)

ans =

0 0 0

1 0 0

-1 -1 1

>> ans==0

ans =

1 1 1

0 1 1

0 0 0

>> sum(sum(ams))

??? Undefined function or variable 'ams'.

>> sum(sum(ans))

ans =
5

>> sum(sum(abs(rem(y,2))))

ans =

>> y=randi([-10 10],3,3)

y=

4 -10 6

-4 -1 6

9 -2 -7

>> sum(sum(rem(y,3)==0))

ans =

>>

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy