Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

MATLAB Command Window Page 1

>> %Stefany Macias Plua


>> date

ans =

'08-Dec-2023'

>> %Ejercicio 1
>> %Literal a
>> r=5

r =

>> radio=pi*r^2

radio =

78.5398

>> %Literal b
>> r=10

r =

10

>> radio_esfera=(4*pi)*r^2

radio_esfera =

1.2566e+03

>> %Literal c
>> r=2

r =

>> V=4/3*pi*r^3

V =

33.5103

>> %Ejercicio 2
>> %Literal a
>> arista=5

arista =

5
MATLAB Command Window Page 2

>> A= arista^2

A =

25

>> %literal b
>> arista=10

arista =

10

>> AS=6*arista^2

AS =

600

>> %literal c
>> arista=12

arista =

12

>> V=arista^3

V =

1728

>> %Ejercicio 3
>> g=6.673*10^-11;
>> mT=6*10^24;
>> m2=7.4*10^22;
>> r=3.9*10^8;
>> F=G*m1*m2/r^2
Unrecognized function or variable 'G'.

>> F=g*mT*m2/r^2

F =

1.9479e+20

>> %Ejericio 4
>> r=linspace(3.8*10^8, 4*10^8, 10)

r =

1.0e+08 *

3.8000 3.8222 3.8444 3.8667 3.8889 3.9111 3.9333 3.9556


3.9778 4.0000
MATLAB Command Window Page 3

>> F=g*(mT*m2)./r.^2

F =

1.0e+20 *

2.0518 2.0280 2.0046 1.9817 1.9591 1.9369 1.9151 1.8936


1.8725 1.8518

>> %Ejercicio 5
>> grados=[20, 45, 60, 75];
>> radianes=[grados*pi/180];
>> G_R=[grados',radianes']

G_R =

20.0000 0.3491
45.0000 0.7854
60.0000 1.0472
75.0000 1.3090

>> G_a_R=[grados',radianes']

G_a_R =

20.0000 0.3491
45.0000 0.7854
60.0000 1.0472
75.0000 1.3090

>> %Ejercicio 5
>> %Funciones trigonometricas
>> %Ejercicio 3.10
>> x=0:0.1:2*pi;
>> seno=sin(x);
>> coseno=cos(x);
>> tangente=tan(x);
>> Tabla=table(x',sin(x)',cos(x)',tan(x)','VariableNames',{'Angulo', 'Seno',
'Coseno','Tangente'})
Error using matlab.lang.makeUniqueStrings>validateExclStrOrElemToChk
First optional argument must be a string array, character vector, cell array of
character vectors, logical array, or
integer array.

Error in matlab.lang.makeUniqueStrings (line 87)


exclStrOrElemToChk = validateExclStrOrElemToChk(excludes, inStr);

Error in matlab.internal.tabular.private.metaDim/checkAgainstVarLabels (line 86)


[modifiedLabels,wasConflicted] = matlab.lang.makeUniqueStrings(obj.labels,
varLabels,namelengthmax);

Error in table (line 373)


t.metaDim = t.metaDim.checkAgainstVarLabels(varnames);
MATLAB Command Window Page 4

>> Tabla=table(x',seno(x)',coseno(x)',tangente(x)','VariableNames',{'Angulo',
'Seno','Coseno','Tangente'})
Array indices must be positive integers or logical values.

>> Tabla=table(x',seno',coseno',tangente','VariableNames',{'Angulo',
'Seno','Coseno','Tangente'})

Tabla =

63×4 table

Angulo Seno Coseno Tangente


______ _________ _______ _________

0 0 1 0
0.1 0.099833 0.995 0.10033
0.2 0.19867 0.98007 0.20271
0.3 0.29552 0.95534 0.30934
0.4 0.38942 0.92106 0.42279

: : : :

5.8 -0.4646 0.88552 -0.52467


5.9 -0.37388 0.92748 -0.40311
6 -0.27942 0.96017 -0.29101
6.1 -0.18216 0.98327 -0.18526
6.2 -0.083089 0.99654 -0.083378

Display all 63 rows.

Tabla =

63×4 table

Angulo Seno Coseno Tangente


______ _________ _________ _________

0 0 1 0
0.1 0.099833 0.995 0.10033
0.2 0.19867 0.98007 0.20271
0.3 0.29552 0.95534 0.30934
0.4 0.38942 0.92106 0.42279
0.5 0.47943 0.87758 0.5463
0.6 0.56464 0.82534 0.68414
0.7 0.64422 0.76484 0.84229
0.8 0.71736 0.69671 1.0296
0.9 0.78333 0.62161 1.2602
1 0.84147 0.5403 1.5574
1.1 0.89121 0.4536 1.9648
1.2 0.93204 0.36236 2.5722
1.3 0.96356 0.2675 3.6021
1.4 0.98545 0.16997 5.7979
1.5 0.99749 0.070737 14.101
1.6 0.99957 -0.0292 -34.233
MATLAB Command Window Page 5

1.7 0.99166 -0.12884 -7.6966


1.8 0.97385 -0.2272 -4.2863
1.9 0.9463 -0.32329 -2.9271
2 0.9093 -0.41615 -2.185
2.1 0.86321 -0.50485 -1.7098
2.2 0.8085 -0.5885 -1.3738
2.3 0.74571 -0.66628 -1.1192
2.4 0.67546 -0.73739 -0.91601
2.5 0.59847 -0.80114 -0.74702
2.6 0.5155 -0.85689 -0.6016
2.7 0.42738 -0.90407 -0.47273
2.8 0.33499 -0.94222 -0.35553
2.9 0.23925 -0.97096 -0.24641
3 0.14112 -0.98999 -0.14255
3.1 0.041581 -0.99914 -0.041617
3.2 -0.058374 -0.99829 0.058474
3.3 -0.15775 -0.98748 0.15975
3.4 -0.25554 -0.9668 0.26432
3.5 -0.35078 -0.93646 0.37459
3.6 -0.44252 -0.89676 0.49347
3.7 -0.52984 -0.8481 0.62473
3.8 -0.61186 -0.79097 0.77356
3.9 -0.68777 -0.72593 0.94742
4 -0.7568 -0.65364 1.1578
4.1 -0.81828 -0.57482 1.4235
4.2 -0.87158 -0.49026 1.7778
4.3 -0.91617 -0.4008 2.2858
4.4 -0.9516 -0.30733 3.0963
4.5 -0.97753 -0.2108 4.6373
4.6 -0.99369 -0.11215 8.8602
4.7 -0.99992 -0.012389 80.713
4.8 -0.99616 0.087499 -11.385
4.9 -0.98245 0.18651 -5.2675
5 -0.95892 0.28366 -3.3805
5.1 -0.92581 0.37798 -2.4494
5.2 -0.88345 0.46852 -1.8856
5.3 -0.83227 0.55437 -1.5013
5.4 -0.77276 0.63469 -1.2175
5.5 -0.70554 0.70867 -0.99558
5.6 -0.63127 0.77557 -0.81394
5.7 -0.55069 0.83471 -0.65973
5.8 -0.4646 0.88552 -0.52467
5.9 -0.37388 0.92748 -0.40311
6 -0.27942 0.96017 -0.29101
6.1 -0.18216 0.98327 -0.18526
6.2 -0.083089 0.99654 -0.083378

Tabla =

63×4 table

Angulo Seno Coseno Tangente


______ _________ _________ _________
MATLAB Command Window Page 6

0 0 1 0
0.1 0.099833 0.995 0.10033
0.2 0.19867 0.98007 0.20271
0.3 0.29552 0.95534 0.30934
0.4 0.38942 0.92106 0.42279
0.5 0.47943 0.87758 0.5463
0.6 0.56464 0.82534 0.68414
0.7 0.64422 0.76484 0.84229
0.8 0.71736 0.69671 1.0296
0.9 0.78333 0.62161 1.2602
1 0.84147 0.5403 1.5574
1.1 0.89121 0.4536 1.9648
1.2 0.93204 0.36236 2.5722
1.3 0.96356 0.2675 3.6021
1.4 0.98545 0.16997 5.7979
1.5 0.99749 0.070737 14.101
1.6 0.99957 -0.0292 -34.233
1.7 0.99166 -0.12884 -7.6966
1.8 0.97385 -0.2272 -4.2863
1.9 0.9463 -0.32329 -2.9271
2 0.9093 -0.41615 -2.185
2.1 0.86321 -0.50485 -1.7098
2.2 0.8085 -0.5885 -1.3738
2.3 0.74571 -0.66628 -1.1192
2.4 0.67546 -0.73739 -0.91601
2.5 0.59847 -0.80114 -0.74702
2.6 0.5155 -0.85689 -0.6016
2.7 0.42738 -0.90407 -0.47273
2.8 0.33499 -0.94222 -0.35553
2.9 0.23925 -0.97096 -0.24641
3 0.14112 -0.98999 -0.14255
3.1 0.041581 -0.99914 -0.041617
3.2 -0.058374 -0.99829 0.058474
3.3 -0.15775 -0.98748 0.15975
3.4 -0.25554 -0.9668 0.26432
3.5 -0.35078 -0.93646 0.37459
3.6 -0.44252 -0.89676 0.49347
3.7 -0.52984 -0.8481 0.62473
3.8 -0.61186 -0.79097 0.77356
3.9 -0.68777 -0.72593 0.94742
4 -0.7568 -0.65364 1.1578
4.1 -0.81828 -0.57482 1.4235
4.2 -0.87158 -0.49026 1.7778
4.3 -0.91617 -0.4008 2.2858
4.4 -0.9516 -0.30733 3.0963
4.5 -0.97753 -0.2108 4.6373
4.6 -0.99369 -0.11215 8.8602
4.7 -0.99992 -0.012389 80.713
4.8 -0.99616 0.087499 -11.385
4.9 -0.98245 0.18651 -5.2675
5 -0.95892 0.28366 -3.3805
5.1 -0.92581 0.37798 -2.4494
5.2 -0.88345 0.46852 -1.8856
5.3 -0.83227 0.55437 -1.5013
5.4 -0.77276 0.63469 -1.2175
MATLAB Command Window Page 7

5.5 -0.70554 0.70867 -0.99558


5.6 -0.63127 0.77557 -0.81394
5.7 -0.55069 0.83471 -0.65973
5.8 -0.4646 0.88552 -0.52467
5.9 -0.37388 0.92748 -0.40311
6 -0.27942 0.96017 -0.29101
6.1 -0.18216 0.98327 -0.18526
6.2 -0.083089 0.99654 -0.083378

>> %Ejercicio 3.11


>> t=0:10;
>> A=4;
>> W=0.6;
>> x=A.*cos(W.*t)

x =

4.0000 3.3013 1.4494 -0.9088 -2.9496 -3.9600 -3.5870 -1.9610


0.3500 2.5388 3.8407

>> tabla==table(t',x','VariableNames',{'Tiempo','Desplazamiento'})
Unrecognized function or variable 'tabla'.

Did you mean:


>> Tabla==table(t',x','VariableNames',{'Tiempo','Desplazamiento'})
Error using ==
Both tables must have the same variables.

>> Tabla=table(t',x','VariableNames',{'Tiempo','Desplazamiento'})

Tabla =

11×2 table

Tiempo Desplazamiento
______ ______________

0 4
1 3.3013
2 1.4494
3 -0.90881
4 -2.9496
5 -3.96
6 -3.587
7 -1.961
8 0.35
9 2.5388
10 3.8407

>> %Ejercicio 6
>> Q=8000;
>> R=1.987;
>> K0=1200;
>> T=100:50:500;
>> T=100:50:500;
MATLAB Command Window Page 8

>> K=K0*exp(-Q./(R.*T))

K =

0.0000 0.0000 0.0000 0.0001 0.0018 0.0121 0.0510 0.1561


0.3820

>> tabla=table(T',K','VariableNames',{'Temperatura','K'})

tabla =

9×2 table

Temperatura K
___________ __________

100 3.9242e-15
150 2.6438e-09
200 2.17e-06
250 0.00012162
300 0.0017812
350 0.012116
400 0.05103
450 0.15615
500 0.38203

>> %Ejercicio 7
>> x=10;
>> b=1:10;
>> r==log(x)./log(b)

ans =

1×10 logical array

0 0 0 0 0 0 0 0 0 0

>> r=log(x)./log(b)

r =

Inf 3.3219 2.0959 1.6610 1.4307 1.2851 1.1833 1.1073


1.0480 1.0000

>> %Ejercicio 8
>> P0=100;
>> r=0.9;
>> t=10;
>> P=P0*exp(r*t)

P =

8.1031e+05

>> %Ejercicio 9
MATLAB Command Window Page 9

>> a=[15 3 22; 3 8 5; 14 3 82]

a =

15 3 22
3 8 5
14 3 82

>> b=[1;5;6]

b =

1
5
6

>> c=[12 18 5 2]

c =

12 18 5 2

>> d=a(:,3)

d =

22
5
82

>> e=[b,d]

e =

1 22
5 5
6 82

>> f=[b;d]

f =

1
5
6
22
5
82

>> g=[a;c(1:3)]

g =

15 3 22
3 8 5
MATLAB Command Window Page 10

14 3 82
12 18 5

>> h=[a(1,3),c(1,2),b(2,1)]

h =

22 18 5

>> %Ejercicio 10
>> b=0:1:10;
>> h=2:1:6;
>> [b,h]=meshgrid(b,h);
>> A=(1/2)*b.*h

A =

0 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000


8.0000 9.0000 10.0000
0 1.5000 3.0000 4.5000 6.0000 7.5000 9.0000 10.5000
12.0000 13.5000 15.0000
0 2.0000 4.0000 6.0000 8.0000 10.0000 12.0000 14.0000
16.0000 18.0000 20.0000
0 2.5000 5.0000 7.5000 10.0000 12.5000 15.0000 17.5000
20.0000 22.5000 25.0000
0 3.0000 6.0000 9.0000 12.0000 15.0000 18.0000 21.0000
24.0000 27.0000 30.0000

>> %Ejercicio 11
>> temperatura=100:100:100;
>> Presiones=100:100:100;
>> R=0.2870;
>> V=(R.*temperatura')./Presiones

V =

0.2870

>> temperatura=100:100:1000;
>> Presiones=100:100:1000;
>> R=0.2870;
>> V=(R.*temperatura')./Presiones

V =

0.2870 0.1435 0.0957 0.0717 0.0574 0.0478 0.0410 0.0359


0.0319 0.0287
0.5740 0.2870 0.1913 0.1435 0.1148 0.0957 0.0820 0.0717
0.0638 0.0574
0.8610 0.4305 0.2870 0.2152 0.1722 0.1435 0.1230 0.1076
0.0957 0.0861
1.1480 0.5740 0.3827 0.2870 0.2296 0.1913 0.1640 0.1435
0.1276 0.1148
1.4350 0.7175 0.4783 0.3588 0.2870 0.2392 0.2050 0.1794
0.1594 0.1435
MATLAB Command Window Page 11

1.7220 0.8610 0.5740 0.4305 0.3444 0.2870 0.2460 0.2152


0.1913 0.1722
2.0090 1.0045 0.6697 0.5022 0.4018 0.3348 0.2870 0.2511
0.2232 0.2009
2.2960 1.1480 0.7653 0.5740 0.4592 0.3827 0.3280 0.2870
0.2551 0.2296
2.5830 1.2915 0.8610 0.6457 0.5166 0.4305 0.3690 0.3229
0.2870 0.2583
2.8700 1.4350 0.9567 0.7175 0.5740 0.4783 0.4100 0.3588
0.3189 0.2870

>> %Ejercicio 12
>> a=magic(5)

a =

17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9

>> %Literal a
>> b=a*2

b =

34 48 2 16 30
46 10 14 28 32
8 12 26 40 44
20 24 38 42 6
22 36 50 4 18

>> %Sí es mágica


>> %Literal b
>> c=a^2

c =

1090 900 725 690 820


850 1075 815 720 765
700 840 1145 840 700
765 720 815 1075 850
820 690 725 900 1090

>> %sí es magica


>> %literal c
>> d=a+2

d =

19 26 3 10 17
25 7 9 16 18
6 8 15 22 24
12 14 21 23 5
MATLAB Command Window Page 12

13 20 27 4 11

>> %si es magica


>> %literal d
>> matriz=[a,b;c,d]

matriz =

17 24 1 8 15 34 48
2 16 30
23 5 7 14 16 46 10
14 28 32
4 6 13 20 22 8 12
26 40 44
10 12 19 21 3 20 24
38 42 6
11 18 25 2 9 22 36
50 4 18
1090 900 725 690 820 19 26
3 10 17
850 1075 815 720 765 25 7
9 16 18
700 840 1145 840 700 6 8
15 22 24
765 720 815 1075 850 12 14
21 23 5
820 690 725 900 1090 13 20
27 4 11

>> %no es una matriz magica


>> %Ejercicio 13
>> %gráficas
>> figure(1)
>>
>> x=linspace(0,10);
>> y=exp(x);
>> plot(x,y)
>> subplot(2,2,1)
>> plot(x,y)
>> %literal b
>> y1=sin(x);
>> subplot(2,2,2)
>> plot(x,y1)
>> %Literal c
>> a=5;
>> b=2;
>> c=4;
>> y2=a*(x.^(2))+b*x+c;
>> subplot(2,2,3)
>> plot(x,y2)
>> %literal d
>> y3=sqrt(x);
>> subplot(2,2,4)
>> plot(x,y3)
>>

You might also like