You are on page 1of 36

>> C=[1 5 2 6;4 10 12 8;9 11 15 7;2 4 6 8]

C=

10

12

11

15

>> sum(C)

ans =

16

30

35

29

>> max(sum(C))

ans =

35

>> sum(C)
sum(C)
|
Error: The input character is not valid in MATLAB statements or
expressions.

>> sum(C')

ans =

14

34

42

20

>> min(sum(C'))

ans =

14

>> cuantos elemntos de la matriz C son menores a su elemnto maximo;


Undefined function 'cuantos' for input arguments of type 'char'.

>> max(C)

ans =

11

15

>> max(max(C))

ans =

15

>> C<(max(max(C)))

ans =

>> sum(C<(max(max(C))))

ans =

>> C.*(C<(max(max(C))))

ans =

10

12

11

6
8
7
8

>> sum(sum(C<(max(max(C)))))

ans =

15

>> %dada la matriz A de M*N con lsa notas de M alumnos en N practicas


obtengo los proedios de los M alumnos sin considerrar la nota menor;
>> a=[1 2 3;5 9 8;1 5 4]

a=

>> a'

ans =

>> sum(a')

ans =

22

10

>> min(a')

ans =

>> [f c]=size(a')

f=

c=

>> [f c]=size(a)

f=

c=

>> (sum(a')-min(a'))/(c-1)

ans =

2.5000

8.5000

4.5000

>> (sum(a')-min(a'))

ans =

17

>> (sum(a')-min(a'))/(c-1)

ans =

2.5000

8.5000

4.5000

>> c=lenght(a(1,:)
c=lenght(a(1,:)
|
Error: Expression or statement is incorrect--possibly unbalanced
(, {, or [.

>> c=length(a(1,:)

c=length(a(1,:)
|
Error: Expression or statement is incorrect--possibly unbalanced
(, {, or [.

>> c=length(a(1,:))

c=

>> %dada una mariz a de orden mxn obtener otra sub matriz b que resulta
de eliminar la priemra y ultima fila y preimra y ultima columna de a;
>> a=[1 5 9 2:5 8 6 2;1 5 9 7;2 2 3 6]
Error using vertcat
Dimensions of matrices being concatenated are not consistent.

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

a=

>> a=(1,:)=[]
a=(1,:)=[]
|
Error: Expression or statement is incorrect--possibly unbalanced
(, {, or [.

>> a(1:)=[]

a(1:)=[]
|
Error: Unbalanced or unexpected parenthesis or bracket.

>> a(1,:)=[]

a=

>> a(:,4)=[]

a=

>> a(4,:)=[]
Index of element to remove exceeds matrix dimensions.

>> a=[1 5 9 2:5 8 6 2;1 5 9 7;2 2 3 6]


Error using vertcat
Dimensions of matrices being concatenated are not consistent.

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

a=

>> a(1,:)=[]

a=

>> a(4,:)=[]
Index of element to remove exceeds matrix dimensions.

>> [f c]=size(a)

f=

c=

>> a(4,:)=[]
Index of element to remove exceeds matrix dimensions.

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

a=

>> [f c]=size(a)

f=

c=

>> a[1 4],:)=[]


a[1 4],:)=[]
|
Error: Unbalanced or unexpected parenthesis or bracket.

>> a([1 4],:)=[]

a=

>> a(:,[1 4])=[]

a=

>> b=a

b=

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

a=

>> b=a(2:3,2:3)

b=

>> %dada una matriz a de orden mxn intercambiar el elemnto mayor con l
elemnto menor de la columna k considerar que todos los elemntos son
iguales;
>> [ma fa]=max(a(:,k))
Undefined function or variable 'k'.

>> [fm cm]=max(a(:,k))


Undefined function or variable 'k'.

>> a[1 5 9;5 6 9;5 8 9]


a[1 5 9;5 6 9;5 8 9]
|
Error: Unbalanced or unexpected parenthesis or bracket.

>> a=[1 5 9;5 6 9;5 8 9]

a=

>> a=[5 5 5;5 5 5;5 5 5]

a=

>> a=[1 5 9;5 6 9;5 8 9]

a=

>> a=[1 5 9;5 6 9;5 8 9]

a=

>> %dada una matriz a de orden mxn intercambiar el elemnto mayor con l
elemnto menor de la columna k considerar que todos los elemntos son
iguales;
>> a=[1 5 9;5 6 9;5 8 9]

a=

>> [a b]=max(a(:,3))

a=

b=

>> max(a(:,3))
Index exceeds matrix dimensions.

>> max(a(:,3)
max(a(:,3)
|
Error: Expression or statement is incorrect--possibly unbalanced
(, {, or [.

>> max(a(:,3))
Index exceeds matrix dimensions.

>> [a b]=max(a(:,3))
Attempted to access a(:,3); index out of bounds because
numel(a)=1.

>> %dada una matriz a de orden mxn intercambiar el elemnto mayor con l
elemnto menor de la columna k considerar que todos los elemntos son
iguales;
>> a=[1 5 9;5 6 9;5 8 9]

a=

>> [a b]=max(a(:,3))

a=

b=

>> [c d]=min(a(:,3))
Attempted to access a(:,3); index out of bounds because
numel(a)=1.

>> %dada una matriz a de orden mxn intercambiar el elemnto mayor con l
elemnto menor de la columna k considerar que todos los elemntos son
iguales;
>> a=[1 5 9;5 6 9;5 8 9]

a=

>> [b c]=max(a(:,3))

b=

c=

>> [d e]=min(a(:,3))

d=

e=

>> t=a(c,3)

t=

>> a(c,3)=a(e,3)

a=

>> a(e,3)=t

a=

>> %practcia de vectores;


>> n=[12 10 9 8 14 15 13 11 18]

n=

12

10

14

15

13

11

>> c=[2 3 5 2 6 3 4 5 3]

c=

>> n>10

ans =

>> n>=10

ans =

>> b=(n>=10)

b=

>> b.*c

ans =

18

>> sum(b.*c)

ans =

26

>> [f c]=size(n)

f=

c=

>> sum(b.*c)/c

ans =

>> n=[12 10 9 8 14 15 13 11 18]

n=

12

10

14

>> c=[2 3 5 2 6 3 4 5 3]

15

13

11

18

c=

>> n>=10

ans =

>> n.*(n>=10)

ans =

12

10

>> sum(n.*(n>=10))

ans =

93

>> [f c]=size(n)

f=

c=

14

15

13

11

18

>> sum(n.*(n>=10))/c

ans =

10.3333

>> n=[12 10 9 8 14 15 13 11 18]

n=

12

10

14

15

13

11

18

>> c=[2 3 5 2 6 3 4 5 3]

c=

>> n>=10

ans =

>> n.*(n>=10)

ans =

12

10

>> [f c]=size(n)

14

15

13

11

18

f=

c=

>> sum(n.*(n>=10))/c

ans =

10.3333

>> n=[12 10 9 8 14 15 13 11 18]

n=

12

10

14

15

13

11

>> c=[2 3 5 2 6 3 4 5 3]

c=

>> [f c]=size(n)

f=

18

c=

>> n.*(n>=10)

ans =

12

10

14

15

13

11

18

>> sum(n.*(n>=10))

ans =

93

>> sum(n.*(n>=10))/7

ans =

13.2857

>> sum(n.*(n>=10))/(c-2)

ans =

13.2857

>> %dado el vector n cuyos elemntos son las notas del exne parcial
identifique que de acuerdo

>> n=[12 10 9 8 14 15 13 11 18]

n=

12

10

14

15

13

11

18

>> c=[2 3 5 2 6 3 4 5 3]

c=

>> [f c]=size(n)

f=

c=

>> n.*(n>=10)

ans =

12

10

14

>> [j k]=size(n.*(n>=10))

j=

15

13

11

18

k=

>> %ca
>> s=[1:n]

s=

Columns 1 through 11

10

11

Column 12

12

>> t=1./(s^2)
Error using ^
Inputs must be a scalar and a square matrix.
To compute elementwise POWER, use POWER (.^) instead.

>> t=1./(s.^2)

t=

Columns 1 through 6

1.0000

0.2500

0.1111

0.0625

0.0400

0.0278

0.0100

0.0083

0.0069

Columns 7 through 12

0.0204

0.0156

0.0123

>> t(2:2:end)=-t(2:2:end)

t=

Columns 1 through 6

1.0000 -0.2500

0.1111 -0.0625

0.0400 -0.0278

Columns 7 through 12

0.0204 -0.0156

0.0123 -0.0100

>> sum(t)

ans =

0.8193

>> s=[1:l]
Undefined function or variable 'l'.

>> s=[1:15]

s=

Columns 1 through 11

0.0083 -0.0069

10

11

Columns 12 through 15

12

13

14

15

>> t=1./(s.^2)

t=

Columns 1 through 6

1.0000

0.2500

0.1111

0.0625

0.0400

0.0278

0.0100

0.0083

0.0069

Columns 7 through 12

0.0204

0.0156

0.0123

Columns 13 through 15

0.0059

0.0051

0.0044

>> t(2:2:end)=-t(2:2:end)

t=

Columns 1 through 6

1.0000 -0.2500

0.1111 -0.0625

Columns 7 through 12

0.0400 -0.0278

0.0204 -0.0156

0.0123 -0.0100

0.0083 -0.0069

Columns 13 through 15

0.0059 -0.0051

0.0044

>> sum(t)

ans =

0.8245

>> s=[1:100]

s=

Columns 1 through 11

10

11

Columns 12 through 22

12

13

14

15

16

17

18

19

20

21

22

28

29

30

31

32

33

39

40

41

42

43

44

Columns 23 through 33

23

24

25

26

27

Columns 34 through 44

34

35

36

37

38

Columns 45 through 55

45

46

47

48

49

50

51

52

53

54

55

61

62

63

64

65

66

72

73

74

75

76

77

83

84

85

86

87

88

94

95

96

97

98

99

Columns 56 through 66

56

57

58

59

60

Columns 67 through 77

67

68

69

70

71

Columns 78 through 88

78

79

80

81

82

Columns 89 through 99

89

90

91

92

93

Column 100

100

>> t=1./(s.^2)

t=

Columns 1 through 6

1.0000

0.2500

0.1111

0.0625

0.0400

0.0278

Columns 7 through 12

0.0204

0.0156

0.0123

0.0100

0.0083

0.0069

0.0039

0.0035

0.0031

0.0021

0.0019

0.0017

0.0013

0.0012

0.0011

0.0009

0.0008

0.0008

0.0006

0.0006

0.0006

0.0005

0.0005

0.0004

0.0004

0.0004

0.0003

Columns 13 through 18

0.0059

0.0051

0.0044

Columns 19 through 24

0.0028

0.0025

0.0023

Columns 25 through 30

0.0016

0.0015

0.0014

Columns 31 through 36

0.0010

0.0010

0.0009

Columns 37 through 42

0.0007

0.0007

0.0007

Columns 43 through 48

0.0005

0.0005

0.0005

Columns 49 through 54

0.0004

0.0004

0.0004

Columns 55 through 60

0.0003

0.0003

0.0003

0.0003

0.0003

0.0003

0.0002

0.0002

0.0002

0.0002

0.0002

0.0002

0.0002

0.0002

0.0002

0.0001

0.0001

0.0001

0.0001

0.0001

0.0001

0.0001

0.0001

0.0001

Columns 61 through 66

0.0003

0.0003

0.0003

Columns 67 through 72

0.0002

0.0002

0.0002

Columns 73 through 78

0.0002

0.0002

0.0002

Columns 79 through 84

0.0002

0.0002

0.0002

Columns 85 through 90

0.0001

0.0001

0.0001

Columns 91 through 96

0.0001

0.0001

0.0001

Columns 97 through 100

0.0001

0.0001

0.0001

0.0001

>> t(2:2:end)=-t(2:2:end)

t=

Columns 1 through 6

1.0000 -0.2500

0.1111 -0.0625

0.0400 -0.0278

Columns 7 through 12

0.0204 -0.0156

0.0123 -0.0100

0.0083 -0.0069

Columns 13 through 18

0.0059 -0.0051

0.0044 -0.0039

0.0035 -0.0031

Columns 19 through 24

0.0028 -0.0025

0.0023 -0.0021

0.0019 -0.0017

Columns 25 through 30

0.0016 -0.0015

0.0014 -0.0013

0.0012 -0.0011

Columns 31 through 36

0.0010 -0.0010

0.0009 -0.0009

0.0008 -0.0008

Columns 37 through 42

0.0007 -0.0007

0.0007 -0.0006

0.0006 -0.0006

Columns 43 through 48

0.0005 -0.0005

0.0005 -0.0005

0.0005 -0.0004

Columns 49 through 54

0.0004 -0.0004

0.0004 -0.0004

0.0004 -0.0003

Columns 55 through 60

0.0003 -0.0003

0.0003 -0.0003

0.0003 -0.0003

Columns 61 through 66

0.0003 -0.0003

0.0003 -0.0002

0.0002 -0.0002

Columns 67 through 72

0.0002 -0.0002

0.0002 -0.0002

0.0002 -0.0002

Columns 73 through 78

0.0002 -0.0002

0.0002 -0.0002

0.0002 -0.0002

Columns 79 through 84

0.0002 -0.0002

0.0002 -0.0001

0.0001 -0.0001

Columns 85 through 90

0.0001 -0.0001

0.0001 -0.0001

0.0001 -0.0001

Columns 91 through 96

0.0001 -0.0001

0.0001 -0.0001

Columns 97 through 100

0.0001 -0.0001

0.0001 -0.0001

>> sum(t)

ans =

0.8224

>> s=[1:100];
>> t=1./(s.^2);
>> t(2:2:end)=-t(2:2:end);
>> sum(t)

ans =

0.8224

>> s=[1:100];
>> t=(s.^2);
>> t(2:2:end)=-t(2:2:end);
>> sum(t)

ans =

-5050

0.0001 -0.0001

>> s=[1:100];
>> s=[1:100]

s=

Columns 1 through 11

10

11

Columns 12 through 22

12

13

14

15

16

17

18

19

20

21

22

28

29

30

31

32

33

39

40

41

42

43

44

50

51

52

53

54

55

61

62

63

64

65

66

Columns 23 through 33

23

24

25

26

27

Columns 34 through 44

34

35

36

37

38

Columns 45 through 55

45

46

47

48

49

Columns 56 through 66

56

57

58

59

60

Columns 67 through 77

67

68

69

70

71

72

73

74

75

76

77

83

84

85

86

87

88

94

95

96

97

98

99

Columns 78 through 88

78

79

80

81

82

Columns 89 through 99

89

90

91

92

93

Column 100

100

>> s=[1:100];
>> t=sum((-1).^(s+1).*(s.^2))

t=

-5050

>> n=[12 10 9 8 14 15 13 11 18]

n=

12

10

14

15

13

11

>> c=[2 3 5 2 6 3 4 5 3]

c=

18

>> n>=10

ans =

>> n.*(n>=10)

ans =

12

10

14

15

13

11

18

15

13

11

18

>> mat=(n.*(n>=10))

mat =

12

10

14

>> mat(1,3)=[]
Subscripted assignment dimension mismatch.

>> n=[12 10 9 8 14 15 13 11 18]

n=

12

10

14

>> c=[2 3 5 2 6 3 4 5 3]

c=

15

13

11

18

>> n>=10

ans =

>> n.*(n>=10)

ans =

12

10

14

15

13

11

18

14

15

13

11

18

>> g=(n.*(n>=10))

g=

12

10

>> g(1,3)=[]
Subscripted assignment dimension mismatch.

>> sum(g)

ans =

93

You might also like