Ejercicios de Graf y Matr en Matlab

6
APELLIDOS Y NOMBRES: CAMAYO ORÉ, Aracelly Yelitza EJERCICIOS SOBRE GRAFICAS BIDIMENCIONALES % EJERCICIO 5.1 GRAFICA DE LAS LETRAS (a)y(b) clc,clear x=0:10; a=exp(x); b=sind(x); subplot(1,2,1),plot(x,a,'r o'),title('GRAFICA EXPONENCIAL'),xlabel('valores de X'),ylabel('valores de Y'),axis equal,grid subplot(1,2,2),plot(x,b,'g *'),title('GRAFICA SENO'),xlabel('valores de X'),ylabel('valores de Y'),gtext('punto medio') % EJERCICIO 5.1 GRAFICA DE LAS LETRAS (b) Y (c) clc,clf,clear figure(1) x=1:10; a=5; b=2; c=4, y=a*x.^2+b.*x+c plot(x,y,'m :'),title('GRAFICA DE LA LETRA C'),xlabel('X'),ylabel('Y'),gtext('punto maximo'),grid figure(2) x=1:10; y=sqrt(x); plot(x,y,'y o'),title('GRAFICA DE LA LETRA D'),xlabel('X'),ylabel('Y'),gtext('punto minimo') % EFERCICIO 5.2 clc,clear,clf x=[12,14,12,22,8,9]; y=[12,14,12,22,8,9]; plot(x,y,'r :'),title('GRAFICA DEL EJERCICIO NUMERO 5.2'),xlabel('X'),ylabel('Y'),grid %GRAFICA DEL EJERCICIO NUMERO 5.3 clc,clf,clear x=-pi:pi; y=sin(x); plot(x,y),title('GRAFICA 1'),xlabel('X'),ylabel('Y'),grid holdon x=-pi:pi; y=sin(2*x); plot(x,y),title('GRAFICA 1'),xlabel('X'),ylabel('Y'),grid holdon x=-pi:pi; y=sin(3*x)

description

ewewew

Transcript of Ejercicios de Graf y Matr en Matlab

APELLIDOS Y NOMBRES: CAMAYO OR, Aracelly YelitzaEJERCICIOS SOBRE GRAFICAS BIDIMENCIONALES% EJERCICIO 5.1 GRAFICA DE LAS LETRAS (a)y(b)clc,clearx=0:10;a=exp(x);b=sind(x);subplot(1,2,1),plot(x,a,'r o'),title('GRAFICA EXPONENCIAL'),xlabel('valores de X'),ylabel('valores de Y'),axis equal,gridsubplot(1,2,2),plot(x,b,'g *'),title('GRAFICA SENO'),xlabel('valores de X'),ylabel('valores de Y'),gtext('punto medio')

% EJERCICIO 5.1 GRAFICA DE LAS LETRAS (b) Y (c)clc,clf,clearfigure(1)x=1:10;a=5;b=2;c=4,y=a*x.^2+b.*x+cplot(x,y,'m :'),title('GRAFICA DE LA LETRA C'),xlabel('X'),ylabel('Y'),gtext('punto maximo'),gridfigure(2)x=1:10;y=sqrt(x);plot(x,y,'y o'),title('GRAFICA DE LA LETRA D'),xlabel('X'),ylabel('Y'),gtext('punto minimo')

% EFERCICIO 5.2clc,clear,clfx=[12,14,12,22,8,9];y=[12,14,12,22,8,9];plot(x,y,'r :'),title('GRAFICA DEL EJERCICIO NUMERO 5.2'),xlabel('X'),ylabel('Y'),grid

%GRAFICA DEL EJERCICIO NUMERO 5.3clc,clf,clearx=-pi:pi;y=sin(x);plot(x,y),title('GRAFICA 1'),xlabel('X'),ylabel('Y'),gridholdonx=-pi:pi;y=sin(2*x);plot(x,y),title('GRAFICA 1'),xlabel('X'),ylabel('Y'),gridholdonx=-pi:pi;y=sin(3*x)plot(x,y),title('GRAFICA 1'),xlabel('X'),ylabel('Y'),grid

%GRAFICA DEL EJERCICIO NUMERO 5.4clc,clf,clearx=-pi:pi;y=sin(x);plot(x,y,'r --'),title('GRAFICA 1'),xlabel('X'),ylabel('Y'),gridholdonx=-pi:pi;y=sin(2*x);plot(x,y,'b -'),title('GRAFICA 1'),xlabel('X'),ylabel('Y'),gridholdonx=-pi:pi;y=sin(3*x)plot(x,y,'g :'),title('GRAFICA 1'),xlabel('X'),ylabel('Y'),grid

%GRAFICA DEL EJERCICIO NUMERO 5.5clc,clf,clearx=-pi:pi;y=sin(x);plot(x,y,'r --'),title('GRAFICA 1'),xlabel('X'),ylabel('Y'),gridholdonx=-pi:pi;y=sin(2*x);plot(x,y,'b -'),title('GRAFICA 1'),xlabel('X'),ylabel('Y'),gridholdonx=-pi:pi;y=sin(3*x)plot(x,y,'g :'),title('GRAFICA 1'),xlabel('X'),ylabel('Y'),gtext('punto de interseccion'),gridL=legend('x=valores de -4:4','y=sin(x)',4)

% EJERCICIO 5.6clc,clear,clffigure(1)t=0:20;Ht=t*100*cosd(45);plot(Ht,t,'r *'),title('(a) GRAFICA DE DISTANCIA HORIZONTAL CONTRA EL TIEMPO'),xlabel('distancia horizontal'),ylabel('tiempo')figure(2)t=0:20;Vt=t*100*sind(45)-(1/2)*9.8*t.^2;plot(t,Vt,'b d'),title('(b) GRAFICA DE DISTANCIA VERTICAL CONTRA EL TIEMPO'),xlabel('tiempo'),ylabel('distancia vertical'),grid

%EJERCICIO 5.7clc,clf,cleart=0:20;Ht=t*100*cosd(45);Vt=t*100*sind(45)-(1/2)*9.8*t.^2;plot(Ht,Vt,'r *'),title('GRAFICA DE DISTANCIA HORIZONTAL-DISTANCIA VERTICAL'),xlabel('DISTANCIA HORIZONTAL'),ylabel('DISTANCIA VERTICAL'),grid

EJERCICIOS SOBRE VECTORES%EJERCICIO 1clc;clearallx=input('Ingrese un vector que tenga 50 valores:');p=mean(x);disp('EL PROMEDIO ES:');disp(p)disp('CUANTOS SON MAYORES QUE EL PROMEDIO?');a=x>p;vmp=sum(a);disp(vmp)disp('VALORES MAYORES QUE EL PROMEDIO');dmp=x(a);disp([dmp])

% EJERCICIO 2clc;clearall% VECTOR AA=3:47% VECTOR BB=5:49% VECTOR RESULTANTEC=A+B

% EJERCICIO 3clc,clearx=input('Ingrese el vector x: ');[m,p]=max(x);disp('MAYOR ELEMENTO');disp(m)disp('POSICION DEL MAYOR ELEMENTO')disp(p)

% EJERCICIO 5clc;clearalldisp('ESTE ES EL VECTOR:');x=[0 34 -12 45 -2 -5 0 98 13 -2 56 3 23 76 0 23 0 10 -23 -65];disp(x)disp('Cuantos son negativos?');negativos=sum(x0);disp(positivos)disp('Cuantos son cero?');cero=sum(x==0);disp(cero)

% EJERCICIO 6clc,clearA=input('Ingrese el primer vector de cien elementos: ');B=input('Ingrese el segundo vector de cien elementos: '); if A==Bdisp('ESTOS VECTORES SON IGUALES');elsedisp('ESTOS VECTORES SON DIFERENTES');end

EJERCICIOS SOBRE MATRICES

% EJERCICIO 1: Defina una matriz de 15 x 15 y luego escriba las ordenes% para obtener la suma de los elementos de cada filas, de los elementos de% cada columna y la suma del total de todo los elementos de la matriz.% Matriz de rango 15 que varia de 5 a 10 con dos decimales.clc,clearformatbankX=5+rand(15)*5;T=X';SumaFilas=sum(T)SumaColumnas=sum(X)SumaTotal=sum(SumaFilas)

% EJERCICIO 2clc,clearx=ones(3)+eye(3)

% EJERCICIO 3: Dada la siguiente matriz A, escribir la orden usando funciones conocidas%para el tratamiento de matrices y transformar dicha matriz en la matriz%inferior. As mismo; la parte resaltada con rojo y lila debe transferirse%a una matriz CC:clc,clearformatshortA=magic(8)A([3:6],[3,4,5,6])=0;A([4,5],[4,5])=1CC=A([3:6],[3:6])

%EJERCICIO 4: Dada la siguiente matriz A, escribir la orden usando funciones conocidas para el tratamiento de matrices para EXTRAER los elementos con color a arreglos AA y BB:clc,clearA=magic(12)AA=A(4,[2,4,6,8,10,12])BB=A([2,4,6,8,10,12],5)

% EJERCICIO 5clc,cleara=magic(6)aa=a(2:6,1:5);aaa=tril(aa);AA=triu(aaa)bb=a(1:5,2:6);bbb=tril(bb);BB=triu(bbb)

% EJERCICIO 6clc,clearA=magic(5)B=A([5,4,3,2,1],[5,4,3,2,1])