Sei sulla pagina 1di 20

PRACTICA 1

LABORATORIO DE MATLAB

1)

>> X=[1 2 3 3 4 6 8]

X=

1 2 3 3 4 6 8

>> a=X(1,6)

a=

>> rem(X,-2)==0

ans =

0 1 0 0 1 1 1

>> sum(ans)

ans =

4
>> mean(X)

ans =

3.8571

>> sum(X>ans)

ans =

>> X(6)=999

X=

1 2 3 3 4 999 8

>> X(1)=33

X=

33 2 3 3 4 999 8

>> X(5:2:7)=33

X=
33 2 3 3 33 999 33

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

>> X(1)=33

X=

33 2 3 3 4 6 8

>> X(5:2:7)=33

X=

33 2 3 3 33 6 33

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

>> Z=[X(1,3) X(1,4) X(1,7)]

Z=

3 3 8

>> %extraer numeros de una matriz(6)

>> Y=X(end,1-1)

??? Attempted to access X(1,0); index must be a positive integer or logical.


>> Y=X(:,7:-1:1)

Y=

8 6 4 3 3 2 1

>> min(X)

ans =

>> mean(X-min(X))

ans =

2.8571

>> mean(X)-min(X)

ans =

2.8571

>> C^=[X(2:1:7)]

??? C^=[X(2:1:7)]

|
Error: The expression to the left of the equals sign is not a valid target for an assignment.

>> C=[X(2:1:7)]

C=

2 3 3 4 6 8

>> mean(C)

ans =

4.3333

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

>> D=[X(3:1:7)]

D=

3 3 4 6 8

>> mean(D)

ans =

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

>> E=[X(1:2:7)]

E=

1 3 4 8

>> Y=E

Y=

1 3 4 8

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

ans =

>> E=[X(1,1) X(1,3) X(1,3)]

E=

1 3 3

>> sum(rem(E,3)==0)
ans =

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

>> rem(X,3)

ans =

1 2 0 0 1 0 2

>> rem(X,3)==0

ans =

0 0 1 1 0 1 0

>> cont(ans9

??? cont(ans9

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

>> cont(ans)

ans =

0 0 1
>> rem(X,3)==3

ans =

0 0 0 0 0 0 0

>> rem(X,3)==0

ans =

0 0 1 1 0 1 0

>> ans

ans =

0 0 1 1 0 1 0

>> X(ans)

ans =

3 3 6

>> sum(ans)
ans =

12

>> Y=X(:,7)=[]

??? Y=X(:,7)=[]

Error: The expression to the left of the equals sign is not a valid target for an assignment.

>> X(:,7)=[]

X=

1 2 3 3 4 6

>> Y=X

Y=

1 2 3 3 4 6

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

>> length(X)

ans =

7
>> R=[a:b)]

??? R=[a:b)]

Error: Unbalanced or unexpected parenthesis or bracket.

>> (a:b)

Warning: Colon operands should not be logical.

ans =

Empty matrix: 1-by-0

>> a=1

a=

>> b=1

b=

>> R=[(a:b)]
R=

>> b=5

b=

>> R=[(a:b)]

R=

1 2 3 4 5

>> c=2

c=

>> b010

??? Undefined function or variable 'b010'.

>> b=10
b=

10

>> Q=[(a:c:b)]

Q=

1 3 5 7 9

>> linspace(a:b:c)

??? Input argument "n" is undefined.

Error in ==> linspace at 21

n = double(n);

>> a=1

a=

>> b=3

b=

3
>> c=15

c=

15

>> linspace(a:b:c)

??? Input argument "n" is undefined.

Error in ==> linspace at 21

n = double(n);

>> linspace(a,b,c)

ans =

Columns 1 through 10

1.0000 1.1429 1.2857 1.4286 1.5714 1.7143 1.8571 2.0000 2.1429 2.2857

Columns 11 through 15

2.4286 2.5714 2.7143 2.8571 3.0000

>> format rat

>> linspace(a,b,c)
ans =

Columns 1 through 7

1 8/7 9/7 10/7 11/7 12/7 13/7

Columns 8 through 14

2 15/7 16/7 17/7 18/7 19/7 20/7

Column 15

>> linspace(a,b,100)

ans =

Columns 1 through 6

1 101/99 103/99 35/33 107/99 109/99

Columns 7 through 12

37/33 113/99 115/99 13/11 119/99 11/9


Columns 13 through 18

41/33 125/99 127/99 43/33 131/99 133/99

Columns 19 through 24

15/11 137/99 139/99 47/33 13/9 145/99

Columns 25 through 30

49/33 149/99 151/99 17/11 155/99 157/99

Columns 31 through 36

53/33 161/99 163/99 5/3 167/99 169/99

Columns 37 through 42

19/11 173/99 175/99 59/33 179/99 181/99

Columns 43 through 48

61/33 185/99 17/9 21/11 191/99 193/99

Columns 49 through 54

65/33 197/99 199/99 67/33 203/99 205/99


Columns 55 through 60

23/11 19/9 211/99 71/33 215/99 217/99

Columns 61 through 66

73/33 221/99 223/99 25/11 227/99 229/99

Columns 67 through 72

7/3 233/99 235/99 79/33 239/99 241/99

Columns 73 through 78

27/11 245/99 247/99 83/33 251/99 23/9

Columns 79 through 84

85/33 257/99 259/99 29/11 263/99 265/99

Columns 85 through 90

89/33 269/99 271/99 91/33 25/9 277/99

Columns 91 through 96
31/11 281/99 283/99 95/33 287/99 289/99

Columns 97 through 100

97/33 293/99 295/99 3

>> logspace(a,b,c)

ans =

Columns 1 through 6

10 3307/238 4151/215 14728/549 16886/453 9841/190

Columns 7 through 12

11443/159 100 16535/119 8302/43 30851/115 20129/54

Columns 13 through 15

9841/19 25189/35 1000

>> logspace(a,b,50)

ans =

Columns 1 through 6
10 1505/137 3198/265 13045/984 1835/126 11327/708

Columns 7 through 12

4095/233 4151/215 2227/105 4823/207 10187/398 41333/1470

Columns 13 through 18

7475/242 2002/59 16886/453 2416/59 14350/319 8648/175

Columns 19 through 24

7383/136 41805/701 2555/39 11443/159 14389/182 4082/47

Columns 25 through 30

10018/105 5555/53 4951/43 17455/138 16535/119 10227/67

Columns 31 through 36

10061/60 5342/29 7892/39 63800/287 9524/39 30851/115

Columns 37 through 42

22987/78 19101/59 19205/54 19144/49 13305/31 17445/37


Columns 43 through 48

9841/19 42674/75 11251/18 25406/37 12069/16 11601/14

Columns 49 through 50

51887/57 1000

>> B=[0:2:20]

B=

Columns 1 through 6

0 2 4 6 8 10

Columns 7 through 11

12 14 16 18 20

>> B.^2

ans =

Columns 1 through 6

0 4 16 36 64 100
Columns 7 through 11

144 196 256 324 400

>>

Potrebbero piacerti anche