Professional Documents
Culture Documents
CURSO
TEMA
: Introduccin al MatLab
: 20061345
2009
Ejercicios:
1. Implemente en Matlab la siguiente funcin, luego plotee
y=f ( x ) =
-
1
x 1
2
Definimos funcion1.m
function[y]=funcion11(x)
y=1./((x.^2)-1)
Evaluamos funcion11(x)
>> x=[-5:0.01:5];
>> [y]=funcion11(x);
>> plot(x,y)
Grfica
60
40
20
-20
-40
-60
-5
-4
-3
-2
-1
x1 + x 2 ; if x 1 >0, x 2>0
x + x 22 ; en los demas casos
2
1
Definimos funcion12.m
function[z]=funcion12(x,y)
if x>0,y>0
z=x+y
else
z=((x.^2)+(y.^2)).^(0.5)
end
Evaluamos funcion12(x)
>>[x,y]=meshgrid([-10:0.5:10]);
>>z=funcion12(x,y);
>>v=z;
>>mesh(x,y,v);
>>colormap winter
>>surf(x,y,v)
Grfica
15
10
0
10
5
0
-5
-10
-10
-5
10
f ( x )=x 2 x5
-
Definimos funcion13.m
function[y]=funcion13(x);
y=((x.^3)-(2*x)-5)
>>
>>
>>
>>
>>
Evaluamos funcion13(x)
x=[0:0.01:2];
y=funcion13(x);
plot(x,y);
xlabel('x');
ylabel('f(x)');
Grfica
-1
-2
-3
f(x)
-4
-5
-6
-7
0.2
0.4
0.6
0.8
1
x
1.2
1.4
1.6
1.8
t=0:0.5:50;
u(51:101)=1;
plot(t,u);
axis([0 50 -0.5 1.5]);
Grfica
1.5
0.5
-0.5
10
15
20
25
30
35
40
45
50
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
-3
-2
-1