MATLAB Command Window >> >> >> >> >> >> >> %David Heredia %Resolucion de ejercicios %2.4 %a r=5 r = 5 >> Ac=pi*rA2 Unrecognized function or variable 'rA2'. >> Ac=pi*r^2 Ac = 78.5398 >> %b >> r2=10; >> Ae=4*pi*r2^2 Ae = 1.2566e+03 >> %c >> r3=2; >> 4/3*pi*r3^3 ans = 33.5103 >> %2.5 >> %a >> ar=5 ar = 5 >> Acu=ar^2 Acu = 25 >> %b >> arl=10; >> Acub=6*arl^2 Page 1 MATLAB Command Window Acub = 600 >> ar2=12; >> %c >> vc=ar2^3 vc = 1728 >> %Operaciones de arreglos >> %2.6 >> %a >> r=3; >> h=[l,5,12]; Unrecognized function or variable 'l'. >> h=[1,5,12]; >> V=pi*r^2*h V = 28.2743 >> >> >> >> 141.3717 %b b=[2 4 6]; h1=12; At=(b*h1)/2 At = 12 24 >> %c >> r=4 r = 4 >> At=(r*r)/2 At = 8 >> h=6 h = 6 >> Vt=At*h 36 339.2920 Page 2 MATLAB Command Window Page 3 Vt = 48 >> %2.7 >> %a >> A=l:l:20; Unrecognized function or variable 'l'. >> >> >> >> >> >> >> >> >> >> >> A=1:1:20; %b B=0:pi/10:2*pi; %c C=linspace(4,20,15); %d D=logspace(10,1000,10); %3.2 %3.1 nthroot(-5, 3); nthroot(-5, 3) ans = -1.7100 >> (-5)^(l/3) Unrecognized function or variable 'l'. >> (-5)A(1/3) (-5)A(1/3) Error: Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses. >> (-5)^(1/3) ans = 0.8550 + 1.4809i >> ans^3 ans = -5.0000 + 0.0000i >> %la diferencia esta en que el nthroot te da el elevado en números i >> %3.2 >> B=l:l:10; Unrecognized function or variable 'l'. >> B=1:1:10; un resultado en números real y MATLAB Command Window Page 4 >> (log(x))./(log(B)) Unrecognized function or variable 'x'. >> (log(x))./(log(B)) Unrecognized function or variable 'x'. >> >> >> >> >> %3.3 p1=100; r=0.9; t=10; P=p1*exp(1).^(r*t) P = 8.1031e+05 >> >> >> >> >> >> %Funciones trigonométricas %3.10 A=0:0.1:2*pi; sin(A); cos(A) ans = Columns 1 through 12 1.0000 0.9950 0.9801 0.9553 0.6967 0.6216 0.5403 0.4536 0.9211 0.8776 0.8253 0.7648 -0.0292 -0.1288 -0.2272 -0.3233 -0.9422 -0.9710 -0.9900 -0.9991 -0.6536 -0.5748 -0.4903 -0.4008 0.4685 0.5544 0.6347 0.7087 Columns 13 through 24 0.3624 0.2675 0.1700 0.0707 -0.4161 -0.5048 -0.5885 -0.6663 Columns 25 through 36 -0.7374 -0.8011 -0.8569 -0.9041 -0.9983 -0.9875 -0.9668 -0.9365 Columns 37 through 48 -0.8968 -0.8481 -0.7910 -0.7259 -0.3073 -0.2108 -0.1122 -0.0124 Columns 49 through 60 0.0875 0.1865 0.2837 0.3780 0.7756 0.8347 0.8855 0.9275 Columns 61 through 63 0.9602 >> cos(A); 0.9833 0.9965 MATLAB Command Window >> tan(A); >> tabla=[A' sin(A)' cos(A)' Page 5 tan(A)'] tabla = 0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 2.0000 2.1000 2.2000 2.3000 2.4000 2.5000 2.6000 2.7000 2.8000 2.9000 3.0000 3.1000 3.2000 3.3000 3.4000 3.5000 3.6000 3.7000 3.8000 3.9000 4.0000 4.1000 4.2000 4.3000 4.4000 4.5000 4.6000 4.7000 4.8000 4.9000 0 0.0998 0.1987 0.2955 0.3894 0.4794 0.5646 0.6442 0.7174 0.7833 0.8415 0.8912 0.9320 0.9636 0.9854 0.9975 0.9996 0.9917 0.9738 0.9463 0.9093 0.8632 0.8085 0.7457 0.6755 0.5985 0.5155 0.4274 0.3350 0.2392 0.1411 0.0416 -0.0584 -0.1577 -0.2555 -0.3508 -0.4425 -0.5298 -0.6119 -0.6878 -0.7568 -0.8183 -0.8716 -0.9162 -0.9516 -0.9775 -0.9937 -0.9999 -0.9962 -0.9825 1.0000 0.9950 0.9801 0.9553 0.9211 0.8776 0.8253 0.7648 0.6967 0.6216 0.5403 0.4536 0.3624 0.2675 0.1700 0.0707 -0.0292 -0.1288 -0.2272 -0.3233 -0.4161 -0.5048 -0.5885 -0.6663 -0.7374 -0.8011 -0.8569 -0.9041 -0.9422 -0.9710 -0.9900 -0.9991 -0.9983 -0.9875 -0.9668 -0.9365 -0.8968 -0.8481 -0.7910 -0.7259 -0.6536 -0.5748 -0.4903 -0.4008 -0.3073 -0.2108 -0.1122 -0.0124 0.0875 0.1865 0 0.1003 0.2027 0.3093 0.4228 0.5463 0.6841 0.8423 1.0296 1.2602 1.5574 1.9648 2.5722 3.6021 5.7979 14.1014 -34.2325 -7.6966 -4.2863 -2.9271 -2.1850 -1.7098 -1.3738 -1.1192 -0.9160 -0.7470 -0.6016 -0.4727 -0.3555 -0.2464 -0.1425 -0.0416 0.0585 0.1597 0.2643 0.3746 0.4935 0.6247 0.7736 0.9474 1.1578 1.4235 1.7778 2.2858 3.0963 4.6373 8.8602 80.7128 -11.3849 -5.2675 MATLAB Command Window 5.0000 5.1000 5.2000 5.3000 5.4000 5.5000 5.6000 5.7000 5.8000 5.9000 6.0000 6.1000 6.2000 -0.9589 -0.9258 -0.8835 -0.8323 -0.7728 -0.7055 -0.6313 -0.5507 -0.4646 -0.3739 -0.2794 -0.1822 -0.0831 Page 6 0.2837 0.3780 0.4685 0.5544 0.6347 0.7087 0.7756 0.8347 0.8855 0.9275 0.9602 0.9833 0.9965 -3.3805 -2.4494 -1.8856 -1.5013 -1.2175 -0.9956 -0.8139 -0.6597 -0.5247 -0.4031 -0.2910 -0.1853 -0.0834 >> %3.11 >> A=l; Unrecognized function or variable 'l'. >> >> >> >> A=1; w=4.5; t= 2; x=A*cos(w*t) x = -0.9111 >> >> >> >> >> %3.16 Q=0:0.05:pi/2; g=8.81; Vi=100; Rango=(Vi^2/g).*sin(2.*Q) Rango = 1.0e+03 * Columns 1 through 12 0 0.8143 0.1133 0.2255 0.3354 0.8891 0.9551 1.0116 0.4420 0.5442 0.6409 0.7312 1.1346 1.1256 1.1054 1.0741 0.3802 0.2716 0.1602 0.0472 Columns 13 through 24 1.0579 1.0937 1.1186 1.1322 1.0321 0.9798 0.9177 0.8464 Columns 25 through 32 0.7667 0.6793 >> %3.17 >> G=[5 57 61 >> median(G) 62 0.5851 68 68 70 0.4851 71 72 75 75 76 76 78 82 83 83 85 93 96]; MATLAB Command Window Page 7 ans = 75 >> P=sum(G)/length(G) P = 71.8000 >> std(G) ans = 18.6169 >> >> >> >> >> %La calificación mas usual %3.18 %Manipulacion de matrices %4.1 A=[15 3 22;3 8 5;14 3 es 82] A = 15 3 14 3 8 3 22 5 82 >> B=[l;5;6]; Unrecognized function or variable 'l'. >> >> >> >> B=[1;5;6]; C=[12 18 5 %a d=A(:,3) d = 22 5 82 >> %b >> e=[d B] e = 22 5 82 >> %c >> f=[d;B] f = 1 5 6 2]; la media MATLAB Command Window Page 8 22 5 82 1 5 6 >> %d >> g=[A; C(1,1:3)] g = 15 3 14 12 3 8 3 18 22 5 82 5 >> %e >> h=[A(1,3) C(1,2) B(2,1)] h = 22 18 5 >> %4.6 >> M=0:1:10; >> p1=13,560; p1 = 13 >> >> >> >> p1=(13.560); p2=(1000); g=9.81; h=M./(p1*g) h = 0 0.0601 0.0075 0.0150 0.0677 0.0752 0.0226 0.0301 0.0376 0.0451 0.0526 0.0003 0.0004 0.0005 0.0006 0.0007 >> h=M./(p2*g) h = 0 0.0008 0.0001 0.0002 0.0009 0.0010 >> %Matrices especiales >> %4.8 >> A1=zeros(3) A1 = MATLAB Command Window 0 0 0 0 0 0 Page 9 0 0 0 >> B1=zeros(3,1) B1 = 0 0 0 >> C1=zeros(1,4) C1 = 0 0 0 0 6 7 2 33 34 29 26 21 22 17 12 13 19 23 27 10 14 18 24 25 20 15 16 11 111 111 111 111 111 111 111 111 >> X2=magic(6) X2 = 35 3 31 8 30 4 1 32 9 28 5 36 >> sum(X2') ans = 111 111 >> sum(X2) ans = 111 111 >> diag(X2) ans = 35 32 2 17 14 11 >> sum(diag(X2)) MATLAB Command Window Page 10 ans = 111 >> fliplr(X2) ans = 24 25 20 15 16 11 19 23 27 10 14 18 26 21 22 17 12 13 6 7 2 33 34 29 1 32 9 28 5 36 >> sum(diag(ans)) ans = 111 >> %4.10 >> Q=X2(1:3,1:3) Q = 35 3 31 1 32 9 6 7 2 42 15 >> sum(Q) ans = 69 >> %no es matriz mag. >> a=magic(5) a = 17 23 4 10 11 24 5 6 12 18 1 7 13 19 25 8 14 20 21 2 15 16 22 3 9 48 10 12 2 14 26 16 28 40 30 32 44 >> %a >> w=a.*2 w = 34 46 8 35 3 31 8 30 4 MATLAB Command Window 20 22 Page 11 24 36 38 50 42 4 6 18 130 130 130 130 >> sum(w) ans = 130 >> %si es una matriz magica >> %b >> E=a.^2 E = 289 529 16 100 121 576 25 36 144 324 1 49 169 361 625 64 196 400 441 4 225 256 484 9 81 >> sum(E) ans = 1055 1105 1205 >> %si es matriz magica >> %c >> t=a+2 t = 19 25 6 12 13 26 7 8 14 20 3 9 15 21 27 10 16 22 23 4 17 18 24 5 11 75 75 75 75 >> sum(t) ans = 75 >> %si es matriz magica >> %d >> R=[a;w] R = 17 23 4 10 24 5 6 12 1 7 13 19 8 14 20 21 15 16 22 3 1105 1055 MATLAB Command Window 11 34 46 8 20 22 18 48 10 12 24 36 Page 12 25 2 14 26 38 50 2 16 28 40 42 4 9 30 32 44 6 18 1 49 169 361 625 3 9 15 21 27 64 196 400 441 4 10 16 22 23 4 225 256 484 9 81 17 18 24 5 11 1 7 13 19 25 2 14 26 38 50 8 14 20 21 2 16 28 40 42 4 15 16 22 3 9 30 32 44 6 18 >> Y=[E ;t] Y = 289 529 16 100 121 19 25 6 12 13 576 25 36 144 324 26 7 8 14 20 >> T=[R Y] T = 17 23 4 10 11 34 46 8 20 22 24 5 6 12 18 48 10 12 24 36 289 529 16 100 121 19 25 6 12 13 576 25 36 144 324 26 7 8 14 20 1 49 169 361 625 3 9 15 21 27 64 196 400 441 4 10 16 22 23 4 225 256 484 9 81 17 18 24 5 11 >> sum(T) ans = 195 1280 >> >> >> >> >> 195 1180 195 195 195 1130 %ya no es amtriz magica, y el orden si afecta las respuestas %Graficas lineales tridimensionales %5.24 x=0:pi/100:20*pi; 1130 1180