Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Leer: n
f=1
for i=1:n
Fin
%Este programa calcula el factorial de un nmero n=input('ingrese un nmero:'); f=1; for i=1:n f=f*i; end
>> factorial ingrese un nmero:3 el factorial es: 6.00 >> factorial ingrese un nmero:5 el factorial es: 120.00
6.1.2. disee un programa con la estructura desde que calcule el total apagar polr la compra de polos. Si se compran 5 o mas polos sele aplicaran un descuento de 15% sobre el total de la compra y si es menor de 5 polos se le aplica un descuento de 12% sobre el total de la compra.
Inicio
Leer: n
sum=0
for i=1:n
Leer: cam
f=f*i
If n>=5
tp=0.88*sum
tp=0.85*sum
Fin
%Este programa calcula el total a pagar por la compra de polos n=input('ingrese la cantidad de polos:');
sum=0; for i=1:n pcam=input('ingrese precio de polo:'); sum=sum+pcam; end if n>=5 tp=0.85*sum; else tp=0.88*sum; end fprintf('el total a pagar es:%8.2f\n',tp)
>> polos ingrese la cantidad de polos:4 ingrese precio de polo:5 ingrese precio de polo:5 ingrese precio de polo:6 ingrese precio de polo:1 el total a pagar es: 14.96 >> polos ingrese la cantidad de polos:5 ingrese precio de polo:5 ingrese precio de polo:5 ingrese precio de polo:6 ingrese precio de polo:1 ingrese precio de polo:4.25 el total a pagar es: 18.06
6.1.3 disee un programa que muestre la tabla de multiplicar del 1 al 30 para cualquier nmero.
Inicio
Leer: n
for i=1:30
multi=n*i fin
multiplicaci n
%Este programa muestra la tabla de multiplicar del 1 al 30 para cualquier %nmero n=input('ingrese un nmero:'); for i=1:30 multi=n*i; fprintf('la multiplicacion es :%8.2f\n',multi) end
>> tabla ingrese un nmero:4 la multiplicacion es : 4.00 la multiplicacion es : 8.00 la multiplicacion es : 12.00 la multiplicacion es : 16.00 la multiplicacion es : 20.00 la multiplicacion es : 24.00 la multiplicacion es : 28.00 la multiplicacion es : 32.00
la multiplicacion es : 36.00 la multiplicacion es : 40.00 la multiplicacion es : 44.00 la multiplicacion es : 48.00 la multiplicacion es : 52.00 la multiplicacion es : 56.00 la multiplicacion es : 60.00 la multiplicacion es : 64.00 la multiplicacion es : 68.00 la multiplicacion es : 72.00 la multiplicacion es : 76.00 la multiplicacion es : 80.00 la multiplicacion es : 84.00 la multiplicacion es : 88.00 la multiplicacion es : 92.00 la multiplicacion es : 96.00 la multiplicacion es : 100.00 la multiplicacion es : 104.00 la multiplicacion es : 108.00 la multiplicacion es : 112.00 la multiplicacion es : 116.00 la multiplicacion es : 120.00
6.1.4 una tienda ofrece un descuento del 12% del total de la compra y un cliente desea saber cuanto deber pagar finalmente por una compra realizada hacer un programa con la estructura desde.
Inicio
Leer: n
sum=0
for i=1:n
leer:
d=0.12*sum sum=sum+comp
tcomp=sum-d
Fin
%Este programa determina el pago final de una compra realizada n=input('ingrese la cantidad de artculos:'); sum=0; for i=1:n comp=input('ingese el precio del artculo:'); sum=sum+comp; end d=0.12*sum; tcomp=sum-d; fprintf('el total de la compra es:%8.2f\n',tcomp)
>> compra ingrese la cantidad de artculos:7 ingese el precio del artculo:5 ingese el precio del artculo:5 ingese el precio del artculo:5 ingese el precio del artculo:5 ingese el precio del artculo:5 ingese el precio del artculo:5 ingese el precio del artculo:5 el total de la compra es : 30.80
Reference page in Help browser doc sin >> help cos COS Cosine of argument in radians. COS(X) is the cosine of the elements of X.
>> help tan TAN Tangent of argument in radians. TAN(X) is the tangent of the elements of X.
doc tan
>> help atan ATAN Inverse tangent, result in radians. ATAN(X) is the arctangent of the elements of X.
>> help acos ACOS Inverse cosine, result in radians. ACOS(X) is the arccosine of the elements of X. Complex results are obtained if ABS(x) > 1.0 for some element.
>> help sec SEC Secant of argument in radians. SEC(X) is the secant of the elements of X.
>> help csc CSC Cosecant of argument in radians. CSC(X) is the cosecant of the elements of X.
>> help cot COT Cotangent of argument in radians. COT(X) is the cotangent of the elements of X.
ASEC Inverse secant, result in radians. ASEC(X) is the inverse secant of the elements of X.
>> help acot ACOT Inverse cotangent, result in radian. ACOT(X) is the inverse cotangent of the elements of X.
sym/acot
>> help sinh SINH Hyperbolic sine. SINH(X) is the hyperbolic sine of the elements of X.
>> help cosh COSH Hyperbolic cosine. COSH(X) is the hyperbolic cosine of the elements of X.
sym/cosh
>> help acosh ACOSH Inverse hyperbolic cosine. ACOSH(X) is the inverse hyperbolic cosine of the elements of X.
>> help atanh ATANH Inverse hyperbolic tangent. ATANH(X) is the inverse hyperbolic tangent of the elements of X.
sym/atanh
>> help exp EXP Exponential. EXP(X) is the exponential of the elements of X, e to the X. For complex Z=X+i*Y, EXP(Z) = EXP(X)*(COS(Y)+i*SIN(Y)).
>> help log LOG Natural logarithm. LOG(X) is the natural logarithm of the elements of X. Complex results are produced if X is not positive.
>> help log10 LOG10 Common (base 10) logarithm. LOG10(X) is the base 10 logarithm of the elements of X. Complex results are produced if X is not positive.
sym/log10
>> help log2 LOG2 Base 2 logarithm and dissect floating point number. Y = LOG2(X) is the base 2 logarithm of the elements of X.
[F,E] = LOG2(X) for each element of the real array X, returns an array F of real numbers, usually in the range 0.5 <= abs(F) < 1, and an array E of integers, so that X = F .* 2.^E. Any zeros in X produce F = 0 and E = 0. This corresponds to the ANSI C function frexp() and the IEEE floating point standard function logb().
SIGN Signum function. For each element of X, SIGN(X) returns 1 if the element is greater than zero, 0 if it equals zero and -1 if it is less than zero. For the nonzero elements of complex X, SIGN(X) = X ./ ABS(X).
ejercicio 2
>> sind(37)
ans =
0.6018
>> tand(53)
ans =
1.3270
>> secd(60)
ans =
2.0000
>> cotd(30)
ans =
1.7321
>> asecd(2)
ans =
60.0000
>> asind(sqrt(2)/2)
ans =
45.0000
>> acscd(2*sqrt(3)/3)
ans =
60.0000
>> acosd(4/5)
ans =
36.8699
>> log(exp(2))
ans =
>> log10(1000)
ans =
>> log10(log10(exp(4)))
ans =
0.2398
>> log(log10(exp(3)))*asin(sqrt(3)/2)
ans =
0.2771
>> log(log10(log(log10(exp(exp(3))))))
ans =
-1.0917