0% found this document useful (0 votes)
22 views4 pages

Tarea 8 Mayo

The document defines matrices A, B, C, and constructs identity and zero matrices. It then performs operations on the matrices like indexing, slicing, assignments. It also generates a random vector and simulates a parabolic trajectory.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views4 pages

Tarea 8 Mayo

The document defines matrices A, B, C, and constructs identity and zero matrices. It then performs operations on the matrices like indexing, slicing, assignments. It also generates a random vector and simulates a parabolic trajectory.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

DEFINE CON OCTAVE LAS SIGUIENTES MATRICES Y COMPRUEBA SUS


DIMENSIONES CON LA FUNCIÓN size.

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

1 2 3 4 5 6
7 8 9 10 11 12

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

1 7
2 8
3 9
4 10
5 11
6 12

>> output_precision(1)
>> C = [0.6 1.5 2.3 -0.5 ; 8.2 0.5 -0.1 -2.0 ; 5.7 8.2 9.0 1.5 ; 1.2 -2.3 -4.3 0.5]
C=

0.6 1.5 2.3 -0.5


8.2 0.5 -0.1 -2.0
5.7 8.2 9.0 1.5
1.2 -2.3 -4.3 0.5

>> size(A)
ans =

2 6

>> size(B)
ans =

6 2

>> size(C)
ans =

4 4

¿CÚAL SERÁ EL RESULTADO DE LAS SIGUIENTES EXPRESIONES EN OCTAVE?

>> a1 = A(2,3)
a1 = 9
>> a2 = A(3,2)
error: A(I,J): row index out of bounds; value 3 out of bound 2
>> b1 = B(2,3)
error: A(I,J): column index out of bounds; value 3 out of bound 2
>> b1 = B(3,2)
b1 = 9
>> c1 = C(2,3)
c1 = -0.1
>> c1 = C(3,2)
c1 = 8.2
>> a3 = A(:,2)
a3 =

2
8

>> c3 = C(4:5,1:3)
error: A(I,J): row index out of bounds; value 5 out of bound 4
>> c4 = C(1:2:5,:)
error: A(I,J): row index out of bounds; value 5 out of bound 4
>> c5 = C([5 2 1], 3:-1:2)
error: A(I,J): row index out of bounds; value 5 out of bound 4
>> D = [4:9; 1:6]
D=

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

>> E = [D A]
E=

4 5 6 7 8 9 1 2 3 4 5 6
1 2 3 4 5 6 7 8 9 10 11 12

>> A(:,2:3) = B(1:2,:)


A=

1 1 7 4 5 6
7 2 8 10 11 12

>> A(1,4:6) = C(4,1:3)


A=

1.0 1.0 7.0 1.2 -2.3 -4.3


7.0 2.0 8.0 10.0 11.0 12.0
>> B(4:6,2) = B(4:6,1)
B=

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

>> C(1,:) = A(1,1:4)


C=

1.0 1.0 7.0 1.2


8.2 0.5 -0.1 -2.0
5.7 8.2 9.0 1.5
1.2 -2.3 -4.3 0.5

2 . CONSTRUYA UNA MATRIZ IDENTIDAD DE 5x5

>> I5 = eye(5)
I5 =

1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1

3. CONSTRUYA UNA MATRÍS DE CEROS DE TAMAÑO 3x2.

>> F = zeros(3,2)
F=

0 0
0 0
0 0

4. CONSTRUYA UN VECTOR ALEATORIO DE TAMAÑO 1000 RELLENO CON


NÚMEROS ALEATORIOS EN EL RANGO 34-20000.

>> vector = round(linspace(32,20000,1000))


>> min(vector)
ans = 32
>> max(vector)
ans = 20000
>> size(vector)
ans =

1 1000

O también

>> maybe = round(34+(20000-34)*rand(1,1000))


>> min(maybe)
ans = 36
>> max(maybe)
ans = 19992
>> size(maybe)
ans =

1 100

>> nicemaybe = sort(maybe)


>> find(nicemaybe == 100)
ans = [](1x0)
>> find( nicemaybe > 100)
>> find( nicemaybe > 10000)
>> leght(find( nicemaybe > 10000))

5. HAGA UN SIMULADOR DE TIRO PARABÓLICO.

>> t = -2:0.1:2
>> x = 100 * t
>> y = -9.81*t.^2+20
>> for i = 1:length(t)
plot(-200,0)
hold on
plot(200,25)
plot(x(i),y(i),'o')
plot(x(1:i),y(1:i),'.')
pause(.05)

Image = getframe;
P = frame2im(Image);
number = num2str(i);
extension = '.bmp';
filename = [number,extension];
imwrite(P,eval('filename'), 'bmp');
hold off
End

You might also like