sabado 12 de abril
DESCRIPTION
domingoTRANSCRIPT
Clase del sábado 12 de abril de 2014
% Números comlejos % Números complejos6+5ians = 6.0000 + 5.0000i6+5jans = 6.0000 + 5.0000i6+5*ians = 41% Variables lógicasA = trueA = 1B = falseB = 0C = A & BC = 0% oD = A | BD = 1E= ~A | BE = 0% EjemplopH = [4 6 1 7 9 12 5 3 7 6 14 13 5 2]
pH = Columns 1 through 8 4 6 1 7 9 12 5 3 Columns 9 through 14 7 6 14 13 5 2% ¿Cuántos valores de pH ácido hay en el vector?x = pH < 7x = Columns 1 through 9 1 1 1 0 0 0 1 1 0 Columns 10 through 14 1 0 0 1 1sum(x)ans = 8% ¿Cuántos valores de pH básico hay en el vector?% ¿Cuántos valores de pH neutro hay en el vector?% ¿Cuántos valores de 3 < pH <=9 hay en el vector?y = pH > 3 & pH <= 9y = Columns 1 through 9 1 1 0 1 1 0 1 0 1 Columns 10 through 14 1 0 0 1 0sum(y)ans = 8
% ERROR:y = 3 > pH <= 9y = Columns 1 through 9 1 1 1 1 1 1 1 1 1 Columns 10 through 14 1 1 1 1 1y = 3 < pH <= 9y = Columns 1 through 9 1 1 1 1 1 1 1 1 1 Columns 10 through 14 1 1 1 1 1y = pH > 3 & pH <= 9 % OKy = Columns 1 through 9 1 1 0 1 1 0 1 0 1 Columns 10 through 14 1 0 0 1 0y = (pH > 3) & (pH <= 9) % OKy = Columns 1 through 9 1 1 0 1 1 0 1 0 1 Columns 10 through 14 1 0 0 1 0pHpH = Columns 1 through 9 4 6 1 7 9 12 5 3 7 Columns 10 through 14 6 14 13 5 2
z=pH.*yz = Columns 1 through 9 4 6 0 7 9 0 5 0 7 Columns 10 through 14 6 0 0 5 0sum(z)ans = 4949/8ans = 6.1250mean(z)ans = 3.5000z = nonzeros(z)z = 4 6 7 9 5 7 6 5mean(z)ans = 6.1250-----------------------------------------------------------------% Conversión de grados Celsius a Fahrenheitclc
clear alldisp('Programa de Conversión de grados Celsius a Fahrenheit')celsius = input('Ingrese una temperatura en grados Celsius:');fahrenheit = 9/5*celsius + 32;disp('La temperatura en grados Fahrenheit es')disp(fahrenheit)-----------------------------------------------------------------
Programa de Conversión de grados Celsius a FahrenheitIngrese una temperatura en grados Celsius:100La temperatura en grados Fahrenheit es 212-----------------------------------------------------------------% Definición de funciones en línea. inlinef = inline('1/x - (x-1)')f = Inline function: f(x) = 1/x - (x-1)ezplot(f)f(5)ans = -3.8000f(5)ans = -3.8000f(0)ans = Inf
fzero(f,5)ans = 1.6180f(ans)ans = -1.1102e-16fzero(f,-5)ans = -0.6180f(ans)ans = 0g = inline('x^2 + y^2')g = Inline function: g(x,y) = x^2 + y^2g(3,4)ans = 25ezplot(g)g = inline('x^2 + y^2 - 25')g = Inline function: g(x,y) = x^2 + y^2 - 25ezplot(g)h = @(x) x^3 - x*sin(x)^2h = @(x)x^3-x*sin(x)^2h = @(x) x.^3 - x.*sin(x).^2h = @(x)x.^3-x.*sin(x).^2
ezplot(h)clch = @(x) x.^3 - x.*sin(x).^2h = @(x)x.^3-x.*sin(x).^2ezplot(h)v = @(x,y) x.^3 - x.*sin(y).^2v = @(x,y)x.^3-x.*sin(y).^2ezplot(v)ezplot(v)5/6*4ans = 3.33335/(6*4)ans = 0.2083(5/6)*4ans = 3.3333diary off