Está en la página 1de 11

DEPARTAMENTO: Ciencias exactas

CARRERA: Electrnica en automatizacin y control

ASIGNATURA: Mtodos numricos

DEBER

NOMBRE: Andrea Crdenas

28 de marzo del 2013- Quito

GRAFICA DE FUNCIONES CODIGO DEL PROGRAMA

%Graficar las siguientes funciones y sus derivadas en una sola grafica de %manera superpuesta syms x; x = -2*pi:0.001:2*pi ; y1=@(x)(cos(x));%@ asigana q sea en funcion de x y2=inline(diff(sym(y1)));%sym simplifica la funcion figure; plot(x,y1(x),'green') title('Grafica funcion y derivada') xlabel('absisas') ylabel('ordenadas') axis ([-8 8 -3 3]) line([-8 8],[0 0]) line([0 0],[-5 5]) hold on plot(x,y2(x),'blue') hold of

CORRIDA DEL PROGRAMA

CODIGO DEL PROGRAMA


% funciones superpuestas e='exp(-x)'; e2='abs(x)'; e3='x^2+1'; q=inline(e); q2=inline(e2); q3=inline(e3); x=-16:0.01:16 ; s=length(x); for n=1:s if x(n)<=-1 y(n)=q(x(n)); end if(x(n)>-1 && x(n)<=1) y(n)=q2(x(n)); end if (x(n)>1) y(n)=q3(x(n)); end end axis([-9 9 -5 5]) plot(x,y) q2(3) r=inline('-x'); r2=inline('-1'); r3=inline('2'); r4=inline('2*x'); for m=1:s if x(m)<=-1 z(m)=r(x(m)); end

if(x(m)>-1 && x(m)<=0) z(m)=r2(x(m)); end if(x(m)>0 && x(m)<=1) z(m)=r2(x(m)); end if (x(m)>1) z(m)=r4(x(m)); end end hold on plot(x,z,'blue')

CORRIDA DEL PROGRAMA

CONVERSIN DE TEMPERATURA CODIGO DEL PROGRAMA

%2.-Tabla de conversin de temperatura que permita pasar de una temperatura a otra. Programa debe permitir pasar de una escala a otra y solicitar al usuario el ingreso de la informacin necesaria para su funcionamiento, adems que siempre debe esperar informacin hasta que se pulse 'S' clc clear all while (1<3) a=char('s');

caso=input('CONVERSION DE TEMPERATURA \n\n1.-Conversion C->F,K,R \n2.-Conversion F->K,R,C\n3.-Conversion R->C,F,K \nPresione s para salir'); if caso==a disp('Fin del programa') break else

switch (caso) case 1 fprintf('Escribe la temperatura en C a convertir.\n'); c=input('c= '); F=32+(9/5)*c K=c+273 R=8/10*c fprintf('La temperatura en grados Fahrenheit: %f\n',F) fprintf('La temperatura en grados Kelvin: %f\n',K) fprintf('La temperatura en grados Reamur: %f\n',R)

case 2 fprintf('Escribe la temperatura en F a convertir.\n'); F=input('F= '); C=((5/9)*(F-32)) K=((5/9)*(F-32))+273 R=(8/10)*(F-32)*(5/9) fprintf('La temperatura en grados Kelvin: %f\n',K) fprintf('La temperatura en grados Reamur: %f\n',R) fprintf('La temperatura en grados Celcius: %f\n',C)

case 3 fprintf('Escribe la temperatura en R a convertir.\n'); R=input('R= '); C=(R*10/8) K=(R*10/8)+273 F=(9/5*R*10/8)+32 fprintf('La temperatura en grados Celcius: %f\n',C) fprintf('La temperatura en grados Fahrenheit: %f\n',F) fprintf('La temperatura en grados Kelvin: %f\n',K)

otherwise fprintf('Esta opcion no existe') end end end

CORRIDA DEL PROGRAMA CONVERSION DE TEMPERATURA 1.-Conversion C->F,K,R 2.-Conversion F->K,R,C 3.-Conversion R->C,F,K Presione s para salir1 Escribe la temperatura en C a convertir. c= 34 F= 93.2000

K= 307

R= 27.2000 La temperatura en grados Fahrenheit: 93.200000 La temperatura en grados Kelvin: 307.000000 La temperatura en grados Reamur: 27.200000 CONVERSION DE TEMPERATURA 1.-Conversion C->F,K,R 2.-Conversion F->K,R,C 3.-Conversion R->C,F,K Presione s para salir2 Escribe la temperatura en F a convertir. F= 93.20 C= 34

K= 307

R= 27.2000 La temperatura en grados Kelvin: 307.000000 La temperatura en grados Reamur: 27.200000 La temperatura en grados Celcius: 34.000000 CONVERSION DE TEMPERATURA 1.-Conversion C->F,K,R 2.-Conversion F->K,R,C 3.-Conversion R->C,F,K Presione s para salir3 Escribe la temperatura en R a convertir. R= 27.20 C= 34

K= 307

F= 93.2000 La temperatura en grados Celcius: 34.000000 La temperatura en grados Fahrenheit: 93.200000 La temperatura en grados Kelvin: 307.000000 CONVERSION DE TEMPERATURA 1.-Conversion C->F,K,R 2.-Conversion F->K,R,C 3.-Conversion R->C,F,K Presione s para salir's' Fin del programa IMGENES DEL PROGRAMA

RAICES DE ECUACIONES CUADRATICAS CODIGO DEL PROGRAMA

3.-Generar una funcin que permita resolver una ecuacin de segundo grado, en donde el usuario ingrese por teclado los coeficientes, y como resultado se tendr cuando es =0; <0; >0

% RAICES DE UNA ECUACION CUADRATICA

fprintf('ECUACION CUADRATICA')

a = input ('\n Ingrese el coeficiente de a: '); b = input ('\n Ingrese el coeficiente de b: '); c = input ('\n Ingrese el coeficiente de c: '); d=b^2-4*a*c; if (d>0) disp(' Raices reales') x1=(-b+sqrt(d))/(2*a); x2=(-b-sqrt(d))/(2*a) ; r=([x1 x2]) end if (d==0) disp(' Raices inguales enteras') x1=(-b+sqrt(d))/(2*a); x2=(-b-sqrt(d))/(2*a) ; r=([x1 x2]) end if (d<0) disp(' Raices imaginarias') x1=(-b+sqrt(d))/(2*a); x2=(-b-sqrt(d))/(2*a); r=([x1 x2]) end

CORRIDA DEL PROGRAMA ECUACION CUADRATICA Ingrese el coeficiente de a: 1 Ingrese el coeficiente de b: -5 Ingrese el coeficiente de c: 6 Raices reales r= 3 2

ECUACION CUADRATICA Ingrese el coeficiente de a: 1 Ingrese el coeficiente de b: 1 Ingrese el coeficiente de c: 1

Raices imaginarias r= -0.5000 + 0.8660i -0.5000 - 0.8660i ECUACION CUADRATICA Ingrese el coeficiente de a: 1 Ingrese el coeficiente de b: -1 Ingrese el coeficiente de c: 0 Raices reales r= 1 0

ECUACION CUADRATICA Ingrese el coeficiente de a: 3 Ingrese el coeficiente de b: 0 Ingrese el coeficiente de c: -12 Raices reales r= 2 -2

IMGENES DEL PROGRAMA

También podría gustarte