U.M.S.N.H
PROGRAMACÍON Y COMPUTACIÓN IQ. GERARDO MEDINA HEREDIA TAREA No. 1 MATLAB UNIDAD 1 -------------------------------------------XITALY MARTINEZ MONDRAGON MATRICULA:172606E SEMESTRE:2 SECCION:02 Morelia, Mich, 24 de septiembre, 2018.
1.-OPERACIONES ARITMÉTICAS DIRECTAS a) >> 1981/14-51.5-9^1/2/18
ans = 89.7500 b) >> (1981/14-51.5-9)^(1/2)/18 ans = 0.5000 c) >> (9^2+27*7)*4/(6^2/3+9^3+7^2+10) ans = 1.3500 d) >> 9^2+27*7*4/6^2/3+9^3+7^2+10 ans = 876 e) >> -2*0.52/(280-294)/sqrt(pi*1.5*exp(-6)*4/3600) ans = 20.6200 f) >> (1.4*(200+460)+2*(70+460)+8.5*(0+460))*(1.4/2+2)^-1 ans = 2.1830e+03 g) >> 21*(10*8*2/12+(10-1)*8*14/12)*(21*8*2/12*10+8*14/12*(10-1))^-1 ans = 5.6154 h) >> 0.171*exp(-8)*(1500^4-530^4)/((1-0.8)/(0.8*8)+1/(1*8)+(1-0-9)/(0.9*8)) ans = -2.9939e+08 I) >> tan(sqrt((sqrt(90/8+1.07722^3)-pi)/1*exp(-4))+2.07) ans = -1.5126 j) >> asin(sqrt(14^2-rem(995,12)-4^2)/22)*10/(2*pi) ans = 1.0062 k) >> (-sqrt(abs(5^3-6^3))/abs((1+(5^2-6^2))/(1-(5^2-6^2)))+12^2)^(1/3)/5 ans = 1.0197
2.-OBTENGA EL RESULTADO DE CADA UNA DE LAS SIGUIENTES EXPRESIONES ALGEBRAICAS EXPRESÁNDOLAS EN FORMA LOGARÍTMICA. A) >> -2/((22-8/(45-2^2)-5/(9^2-8)))+(15+6)/(34-12) ans = 0.8625 B) >> (35+(13-28)/24/26-(28-13)/18)-((32-8)/(5-22)-5.5/(18+6)/24)+9.25 ans = 44.8139 C) >> 1/((1/(12.58)+(1/(3.65)+(1/6.557)))) ans = 1.9764 D) >> sqrt(sqrt(0.0568)+((956.45/300/[1+(0.5/1.789*exp(4))^(9/16)]^(6/9))^(1/6))) ans = 1.1133 E) >> 1.5+(-22.8*6/sqrt(6^2+1)/(2.45-(-25*8)/sqrt(7^2+1))) ans = 0.7683 F) >> sqrt((0.98)^2+1)/(0.98-1)*log(20/(2.45-1-0.98+sqrt((0.98)^2+1)))/(log(20/(2.45-10.98+sqrt((0.98)^2+1))/(2/(2.45-1-0.98-sqrt((0.98)^2+1))))) ans = -21.3876 +41.8858i
nota no esta definida
G)>>1.75*(46.79/52.64)^(0.14)*[2.45*exp(5)+12.6*(((3.16*exp(4))*(2.45*exp(5))*(2.75/ (155))^(0.4)))^(1/3)] ans = 1.1294e+03 H) >> 2.71828^(2^(5+1))*log(4*8^2) ans =
3.4574e+28 J) >> (3*15-60/15)-(2*5*6^2/(361-1))+(380/190) ans =
42 K) >> atan(4.8/5.7)-(4.8*5.7/((4.8)^2+(5.7)^2)) ans = 0.2072 L) >> (6.4)^2*acos((6.4-8.6)/6.4)-(6.4-8.6)*sqrt(2*6.4*(8.6-(8.6)^2)) ans = 78.7130 +63.6332i M) >> 234.5+(1/(35-[(16+234.5/(9+234.5))]^(2.5)-(1/((16+234.5)+(9+234.5))))) ans = 234.4991 N) >> 8*10*12/(4*sqrt((15*(15-8)*(15-10)*(15-12)))) ans = 6.0474 O) >> 4.355*241.5/(0.794*89.4)/(1+123.4*4501.78/((97.4*2.457*10^(-3)*0.871))) ans = 5.5594e-06 P) >> (-0.82*512/((3.15-0.258)^2))+(116.8*(2*(0.258)+2*(0.258))/ ([3.15*(3.15+0.258)+0.258*(3.15-0.258)^2])) ans = -40.8490 Q) >> (2*pi*(1.457)^2*8.41/(1.44*10^(-2))^5)*(exp(1.457*8.41/(1.44*10^-2*0.9*515.4)))^(-1) ans = 2.8933e+10 R) >> (0.85*130*2815/((1.56*(120-100))))+130*0.85*1.56*2815/((5204.8)*(135-120)-(205100)/(log((135-120/(205-100))))) ans =9.9760e+03
4.-HACIENDO USO DEL OPERADOR: DOS PUNTOS… a) >> x=[1:4:97] x =1 5 73 77 81
85
9
13 89
17 93
21 97
25
29
33
37
41
45
49
53
57
61
65
69
b) >> x=[50:-5:-25] x= 50
45
40
35
30
25
20
15
10
5
0
-5 -10 -15 -20 -25
c) >> x=[1:25] x= 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
>> y=(1./x) y= 1
1/2
1/3
1/4
1/9
1/10
1/11
1/12
1/17
1/18
1/19
1/5
1/6
1/13
1/20
1/7
1/14
1/21
1/8
1/15
1/22
1/23
6
7
1/16 1/24
d) >> x=[0:1:29] >> x=[0:29] x= 0
1
2
3
4
5
8
9
10
11
12
16
17
18
19
20
21
24
25
26
27
28
29
13
14
15
22
23
>> y=[1:30] y= 1
2
3
4
5
9
10
11
12
6
13
7 14
17
18
19
20
21
22
25
26
27
28
29
30
0
1/2
2/3
3/4
4/5
5/6
8/9
9/10
10/11
15/16
16/17
8 15
16
23
24
6/7
7/8
>> z=[x./y] z=
17/18
11/12 18/19
12/13 19/20
13/14 20/21
14/15 21/22
1/25
22/23
23/24
24/25
25/26
26/27
27/28
28/29
29/30 e) >> x=[1:15] x =1 9
2
3
10
4
11
5
12
13
6
7
8
14
15
>> y=[sqrt(x)] y= 1 1393/985 3363/1189 3 1921/496
1351/780 2 721/228 1257/379
2889/1292 1351/390
2158/881 4936/1369
2024/765 3476/929
f) >> x=[1:50] x =1 9
2
3
10
4 11
5 12
6 13
7 14
8 15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
9
16
25
36
49
64
>> y=[x.^2] y =1 81
4 100
121
144
169
196
225
256
289
324
361
400
441
484
529
576
625 1089 1681 2401
676 1156 1764 2500
729 1225 1849
784 1296 1936
841 1369 2025
900 1444 2116
961 1024 1521 1600 2209 2304
g) >> x=[1:15] x =1 9
2 10
3 11
4 12
5 13
6
7
14
15
8
>> y=[2.^x-1] y =1 511
3 1023
h) >> x=[3:25]
7 2047
15 4095
31
63 8191
127 16383
255 32767
x =3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
6
7
8
9
>> y=[4:26] y =4
5
10
11
12
13
14
15
16
17
18
20
21
22
23
24
25
26
19
>> z=[x.*y] z =12
20
30
42
56
72
90
110
132
156
182
210
240
272
306
380
420
462
506
552
600
650
342
i) >> x=[1:25] x=1 9 18
2 10 19
3 11 20
4
5
12 21
13 22
6
7
8
14 23
15 24
1/9 -1/18
-1/10 1/19
16 25
17
>> y=(-1).^(x-1)./x y = 1 -1/2 1/3 1/13 -1/14 1/21 -1/22
-1/4 1/5 1/15 1/23
-1/6 1/7 -1/8 -1/16 1/17 -1/24 1/25
1/11 -1/20
-1/12
k) >> x=[-5:1:10] x = -5 3
-4 4
-3 5
-2
-1
6
0
7
1
8
2
9
10
>> y=(2.^x) y =1/32 8
1/16 16
1/8 32
1/4 64
1/2 128
1 256
2 512
4 1024
l) >> x=[1:30] x =1 9
2 10
3 11
4 12
5 13
6
7
8
14
15
16
17
18
19
20
21
22
25
26
27
28
29
30
23
24
>> y=(x.^(1./x)) y =1 1393/985 1149/886 1745/1367
949/658 1393/985 3491/2773 1113/895
1021/740 818/665
980/727 659/541
787/596 1298/1075
224/187 473/411 374/333
1785/1501 1153/976 1119/953 1075/938 1540/1349 1283/1128 905/808
1017/871 450/397
381/328 1140/1009
1067/923 1328/1179
m) >> x=[-4:1:10] x = -4 4
-3 5
-2
-1
6
0
7
1
8
2
9
3
10
>> y=(x.^x) y =1/256 256
-1/27
1/4
3125
-1
46656
1
1
4
1/2
3/5
27
823543
o) >> x=[0.1:0.1:1.5] x =1/10 9/10
1/5 1
3/10 11/10
2/5 6/5
13/10
7/10
7/5
4/5
3/2
>> y=cos(x)./x y =11950/1201 1475/301 519/475 661/759 163/236
429/794
2745/862
774/1877
1476/641
292/967
1699/968
478/2323
923/671
591/4868
229/4856
p) >> x=[0,2,0,2,0] x =0
2
0
2
0
>> y=[x,x,x,x,x] y= 0
2
0
2
0
0
2
0
2
0
0
2
0
2
0
0
2
0
2
0
0
2
0
2
R) >> x=[3:15] x=3 11
4
5
6
12
13
7
14
8
9
10
15
>> y=x./(x+1).^2 y =3/16
4/25
5/36
10/121
11/144
12/169
6/49
7/64
13/196
8/81
14/225
9/100
15/256
S) >> x=[1:12] x =1
2
3
4
9
10
11
12
5
6
7
8
>> y=1./2.^x y = 1/2
1/4
1/8
1/16
1/32
1/64
1/128
0
1/256
1/512
1/1024
1/2048
1/4096
T) >> x=[2:2:100]
x =2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
62
64
66
68
70
72
74
76
78
80
82
84
86
88
90
92
94
96
98
100
>> y=1./(2.*x) y =1/4 1/36 1/72
1/8 1/40 1/76
1/12 1/44 1/80
1/16 1/48 1/84
1/20 1/52 1/88
1/24 1/56 1/92
1/28 1/32 1/60 1/64 1/68 1/96 1/100
U) >> x=[1:20] X= 1
2
3
4
9
10
11
17
18
19
5
12
6 13
7 14
8 15
16
20
>> y=(-1).^x.*x./(x+1).^2 y = -1/4
2/9
-3/16
8/81 -9/100
10/121
-15/256
16/289
4/25 -11/144
-17/324
-5/36
6/49
12/169
-13/196
18/361
-19/400
-7/64 14/225
20/441
V) >> x=[0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1] x=0
1
0 0
0
1 1
1
0 0
0
1
1
0
0
1
1
0
1
1
>> y=[x,x,x,x,x] y= 1
0 0
1
0
1
0
1
0
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
W) >> x=[1:24] x =1
2
9
3
10
17
4
11
18
5
12
13
19
20
21
64/27
625/256
6
7
8
14
15
16
22
23
24
>> y=(1+1./x).^x y= 2 9/4 6884/2683 1097/425 961/365 1497/563
1065/428
991/393
2437/957
10777/4155 1737/667 1283/491 1043/398 1374/523 153/58 1707/646 3443/1301 3877/1463 926/349 6298/2371 1871/703 1513/568
X) >> x=[1:24] x =1
2
9
3
10
17
4
11
18
5
12
13
6
7
8
14
15
16
19
20
21
22
23
24
3
6
10
15
21
28
36
45
55
66
78
91
105
120
153
171
>> y=x.*(x+1)./2 y =1
190
210
231
253
136 276
5.-ACCESO A LOS DIFERENTES ELEMENTOS DENTRO DE UN VECTOR. >> randn('state',sum(100*clock)),t=fix(abs(randn(1,10)*10)) t= 14
3
17
12
3
7
1
20
11
13
300
>> t(5) ans = 3
>> t(2:7) ans = 3
17
12
3
17
12
7
1
>> t(1:end) ans = 14
3
3
7
1
20
>> t(2:end-1) ans = 3
17
12
>> t(3:2:8) ans = 17
3
1
>> t(8:-2:3) ans = 20
>> t(:) ans = 14 3 17 12
7
12
3
7
1
20
11
11
13
3 7 1 20 11 13
>> t(end:-2:1) ans = 13
20
7
12
3
17
12
3
>> t(t>0) ans = 14
3
7
1
20
11
13
1
7
>> t([1:length(t)/2,end:-1:length(t)/2]) ans = 14
3
17
12
3
>> t(t>=5&t<=15) ans = 14
12
7
11
13
14
12
>> t([3,6,1,1,4]) ans = 17
7
>> [t',t'] ans = 14
14
3
3
14
13
11
20
3
17
17
12
12
3
3
7
7
1
1
20
20
11
11
13
13
>> [t;t] ans = 14
3
17
12
3
7
1
20
11
13
14
3
17
12
3
7
1
20
11
13
>> [t,t;t,t] ans = 14 13
3
17
12
3
7
1
20
11
13
14
3
17
12
3
7
1
20
11
14 13
3
17
12
3
7
1
20
11
13
14
3
17
12
3
7
1
20
11
>> [t',t';t',t'] ans = 14
14
3
3
17
17
12
12
3
3
7
7
1
1
20
20
11
11
13
13
14
14
3
3
17
17
12
12
3
3
7
7
1
1
20
20
11
11
13
13
>> [t';t';[t,t]'] ans = 14 3 17 12 3 7 1 20 11 13 14 3 17 12 3 7 1
20 11 13 14 3 17 12 3 7 1 20 11 13 14 3 17 12 3 7 1 20 11 13
>> sum(t) ans = 101
>> prod(t) ans = 514594080
>> median(t) ans = 11.5000
>> sort(t) ans = 1
3
3
7
11
12
13
14
17
20
11
12
13
14
17
20
3
3
1
>> sort(t,'ascend') ans = 1
3
3
7
>> sort(t,'descend') ans = 20
17
14
13
12
11
7
17
12
3
7
1
12
3
7
20
3
20
11
>> t(end)=[] t= 14
3
20
11
>> t(end-2)=[] t= 14
3
17
11
>> t([6,2])=[] t= 14
17
12
6.- CREACION DE MATRICES A TRAVEZ DE VECTORES >> p=[2;6;4]
p= 2 6 4 >> q=[8,3,5] q= 8
3
5
>> r=[10,1,0,7,9] r= 10
1
0
7
9
>> s=[-5;-2;-9;-6;-8] s= -5 -2 -9 -6 -8
A) >> a=[q;p,p,p] a= 8
3
5
2
2
2
6
6
6
4
4
4
B) >> b=[p';q',flipud(q'),q';fliplr(p')] b= 2
6
4
8
5
8
3
3
3
5
8
5
4
6
2
C)>> c = [q',p;p(end:-1:1),q(end:-1:1)'] c= 8
2
3
6
5
4
4
5
6
3
2
8
D)>> d= [[s(end:-1:1),r(end:-1:1)'],[p';q;p(end:-1:1)';q(end:-1:1);p']] d= -8
9
2
6
4
-6
7
8
3
5
-9
0
4
6
2
-2
1
5
3
8
-5 10
2
6
4
E)>> e =[s,r',s(end:-1:1),r(end:-1:1)'] e= -5 10 -8
9
-2
1 -6
7
-9
0 -9
0
-6
7 -2
1
-8
9 -5 10
F) >> f = [[q;p(end:-1:1)';q(end:-1:1);p';q*2],[s]] f= 8
3
5 -5
4
6
2 -2
5
3
8 -9
2
6
4 -6
16
6 10 -8
G) >> g=[r;q'+p,p,-2.*flipud(p),q',-1.*flipud(q')] g= 10
1
0
7
9
10
2
-8
8
-5
9
6 -12
3
-3
9
4
5
-8
-4
H)>> h= [[-1.*rot90(s,3)];rot90(P,2),q',[q;rot90(q,2);rot90(P,3)];rot90(r,2)] h= 8
6
9
2
5
4
8
8
3
5
6
3
5
3
8
2
5
4
6
2
9
7
0
1 10
I) >> i=[rot90(s,3);[q',[rot90(p,3);rot90(q,2);p';],rot90(q)];rot90(r,2)] i = -8
-6
-9
-2
-5
8
4
6
2
5
3
5
3
8
3
5
2
6
4
8
9
7
0
1
10
7.-ACCESO A LOS DIFERENTES ELEMENTOS DENTRO DE UNA MATRIZ >> rand('state',sum(100*clock)),R=reshape(randperm(36),6,6) R= 13
27
18
6
33
31
32
9
29
25
24
11
5
26
19
35
8
1
7
28
4
34
36
2
14
12
22
30
21
15
20
17
10
23
3
16
>> R(5,3) ans = 22
>> R(2:end,:) ans = 32
9
29
25
24
11
5
26
19
35
8
1
7
28
4
34
36
2
14
12
22
30
21
15
20
17
10
23
3
16
>> R(:,1:end) ans = 13
27
18
6
33
31
32
9
29
25
24
11
5
26
19
35
8
1
7
28
4
34
36
2
14
12
22
30
21
15
20
17
10
23
3
16
>> R(2:end-1,2:end-1) ans = 9
29
25
24
26
19
35
8
28
4
34
36
12
22
30
21
>> R(1:2:5,:) ans = 13
27
18
6
33
31
5
26
19
35
8
1
14
12
22
30
21
15
>> R(5:-2:3,:) ans = 14
12
22
30
21
15
5
26
19
35
8
1
>> R(3:4,1:2) ans = 5
26
7
28
>> R(:) ans = 13 32 5 7 14 20 27 9 26 28
12 17 18 29 19 4 22 10 6 25 35 34 30 23 33 24 8 36 21 3 31 11 1 2 15 16
>> R(3:end-1,2:end-2) ans = 26
19
35
28
4
34
12
22
30
>> R(:,[1:length(R)/2,end:-1:length(R)/2]) ans = 13
27
18
31
33
6
18
32
9
29
11
24
25
29
5
26
19
1
8
35
19
7
28
4
2
36
34
4
14
12
22
15
21
30
22
20
17
10
16
3
23
10
>> R([3,6,1,1,4],:) ans = 5
26
19
35
8
1
20
17
10
23
3
16
13
27
18
6
33
31
13
27
18
6
33
31
7
28
4
34
36
2
>> R([3,6,2],[1,4,5]) ans = 5
35
8
20
23
3
32
25
24
>> [R,R;R,R] ans = 13
27
18
6
33
31
13
27
32
9
29
25
24
11
32
9
5
26
19
35
8
1
5
26
18 29 19
6
33
31
25
24
11
35
8
1
7
28
4
34
36
2
7
28
4
34
14
12
22
30
21
15
14
12
22
30
21
20
17
10
23
3
16
20
17
10
23
3
16
13
27
18
6
33
31
13
27
18
6
33
31
32
9
29
25
24
11
32
9
25
24
11
5
26
19
35
8
1
5
26
19
35
8
1
7
28
4
34
36
2
7
28
4
34
36
2
14
12
22
30
21
15
14
12
22
30
21
20
17
10
23
3
16
20
17
10
23
3
29
36
2 15
15 16
>> sum(R) ans = 91 119 102 153 125
76
>> prod(R) ans = 4076800
36088416
8727840 123165000
14370048
>> median(R) ans = 13.5000 21.5000 18.5000 27.5000 22.5000 13.0000
>> sort(R) ans = 5
9
4
6
3
1
7
12
10
23
8
2
13
17
18
25
21
11
14
26
19
30
24
15
20
27
22
34
33
16
32
28
29
35
36
31
163680
>> sort(R,'ascend') ans = 5
9
4
6
3
1
7
12
10
23
8
2
13
17
18
25
21
11
14
26
19
30
24
15
20
27
22
34
33
16
32
28
29
35
36
31
>> sort(R,'descend') ans = 32
28
29
35
36
31
20
27
22
34
33
16
14
26
19
30
24
15
13
17
18
25
21
11
7
12
10
23
8
2
5
9
4
6
3
1
>> R(end,:)=[] R= 13
27
18
6
33
31
32
9
29
25
24
11
5
26
19
35
8
1
7
28
4
34
36
2
14
12
22
30
21
6
33
>> R(:,end)=[] R= 13
27
18
15
32
9
29
25
24
5
26
19
35
8
7
28
4
34
36
14
12
22
30
21
>> R(1:2,:)=[] R= 5
26
19
35
8
7
28
4
34
36
14
12
22
30
21
>> R([4,2],:)=[] Matrix index is out of range for deletion.
>> R(:,[4,2])=[] R= 5
19
8
7
4
36
14
22
21
>> R(:,:)=[] R= 0×3 empty double matrix
10.-GENERE LAS SIGUIENTES MATRICES DE VALORES…
>> a=[(1:1:5);(2:1:6);(3:1:7);(4:1:8)] a =1
2
3
4
5
2
3
4
5
6
3
4
5
6
7
4
5
6
7
8
>> b=[(8:-1:4);(7:-1:3);(6:-1:2);(5:-1:1)] b =8
7
6
5
4
7
6
5
4
3
6
5
4
3
2
5
4
3
2
1
>> c=[(8:-2:0);(7:-3:-5);(6:-4:-10);(5:-5:-15)] c =8
6
4
2
0
7
4
1 -2 -5
6
2 -2 -6 -10
5
0 -5 -10 -15
>> d=[1,2,3,4,5;1,4,9,16,25;2,4,6,8,10;1,8,27,64,125] d =1
2
3
4
5
1
4
9 16 25
2
4
6
1
8 27 64 125
8 10
>>e=[1,2,4,7,11;125,64,27,8,1;126,66,31,15,12;-124,-62,-23,-1,10] e =1
2
4
125 64 27
7 11 8
1
126 66 31 15 12 -124 -62 -23 -1 10
>>f=[0,3,6,9,12;0,1,3,6,10;0,4,8,12,16;15,10,5,0,-5] f=0
3
6
9 12
0
1
3
6 10
0
4
8 12 16
15 10
5
0 -5
a) >> a=[1,2,3,4,5;2,3,4,5,6;3,4,5,6,7;4,5,6,7,8] a =1
2
3
4
5
2
3
4
5
6
3
4
5
6
7
4
5
6
7
8
>> a(:,[1,3,5])=[] a =2
4
3
5
4
6
5
7
>> vic=a vic = 2
4
3
5
4
6
5
7
B) >> b(:,[2,4])=[] b =8
6
4
7
5
3
6
4
2
5
3
1
>> filB=b filB =8
6
4
7
5
3
6
4
2
5
3
1
C) >> c(:,[2,4])=[] c =8 7
4
0
1 -5
6 -2 -10 5 -5 -15 >> filasC=c filasC = 8
4
0
7
1 -5
6 -2 -10 5 -5 -15
E) w= e([1,2,3], 1:5) w= 1
2
4
125 64 27
7 11 8
1
126 66 31 15 12
G) >> a([1,2,3,4,5],1)=0 a= 0
2
3
4
5
0
3
4
5
6
0
4
5
6
7
0
5
6
7
8
0
0
0
0
0
H) >> b([1:4],3)=(1:1:4) b= 8
7
1
5
4
7
6
2
4
3
6
5
3
3
2
5
4
4
2
1