Práctica 1 Matlab
Práctica 1 Matlab
>> syms x y z
>>f=x^3-x
f =x^3 – x
>>g=(x^2+3*x+2)/(x+2)
>>h=x^2+y^3
h =x^2 + y^3
>> e1=x+y-5
e1 =x + y – 5
>> e2=x-y-1
e2 =x - y - 1
>>rf=factor(f)
rf =x*(x - 1)*(x + 1)
>>rg=simplify(g)
rg =x + 1
>>rfx=diff(f,x)
rfx =3*x^2 – 1
d) Integrar f respecto de x, mediante comandos de MATLAB
>>rfx1=int(f,x)
rfx1 =(x^2*(2*x + 3))/6
>> rh=subs(h,{x,y},{1,2})
rh =9
>> recf=solve(f,x)
recf =
0
1
-1
>> rSec=solve(e1,e2)
rSec = x: [1x1 sym]
y: [1x1 sym]
>> RSEC=[rSec.x,rSec.y]
RSEC =[ 3, 2]
>> x=-2:0,01;2;
x = -2 -1 0
>> y=x.^2;
>> plot(x,y)
3.5
2.5
1.5
0.5
0
-2 -1.8 -1.6 -1.4 -1.2 -1 -0.8 -0.6 -0.4 -0.2 0
x=linspace(-2,2,20);
>> y=x.^2;
>> plot(x,y)
3.5
2.5
1.5
0.5
0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
>> x=-2:0.01;2;
>> y=x.^2;
>>
grafico 1
3
2.5
1.5
0.5
0 0
-0.5
-1
-3 -2 -1 0 1 2 3
eje x
>> x=-2:0.01;2;
>> y=x.^2;
2.5
1.5
0.5
0 0
-0.5
-1
-3 -2 -1 0 1 2 3
eje x
>> plot(x,y,'r')
3.5
2.5
1.5
0.5
0
-2 -1.8 -1.6 -1.4 -1.2 -1 -0.8 -0.6 -0.4 -0.2 0
>> plot(x,y,'m')
4
3.5
2.5
1.5
0.5
0
-2 -1.8 -1.6 -1.4 -1.2 -1 -0.8 -0.6 -0.4 -0.2 0
>> plot(x,y,'o')
4
3.5
2.5
1.5
0.5
0
-2 -1.8 -1.6 -1.4 -1.2 -1 -0.8 -0.6 -0.4 -0.2 0
>> plot(x,y,'+')
3.5
2.5
1.5
0.5
0
-2 -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s(x1);
>> x2=0:0.1:pi;
>> y2=sin(x2);
>> subplot(1,2,1),plot(x1,y1)
>> subplot(1,2,2),plot(x2,y2)
1 1
0.9 0.9
0.8 0.8
0.7 0.7
0.6 0.6
0.5 0.5
0.4 0.4
0.3 0.3
0.2 0.2
0.1 0.1
0 0
-1 -0.5 0 0.5 1 0 1 2 3 4
>> x1=-1:0.1:1;
>> y1=abs(x1);
>> x2=-2*pi:0.1:2*pi;
>> y2=sin(x2);
>> x3=1:0.1:5;
>> y3=log(x3);
>> subplot(2,2,1),plot(x1,y1,'r'),grid
>> subplot(2,2,2),plot(x2,y2,'g'),grid
>> subplot(2,2,3),plot(x3,y3,'m'),grid
>> subplot(2,2,4),ezplot('x^2/9-y^2/4=1',[-5,5]),grid
1
1
0.8
0.5
0.6
0
0.4
0.2 -0.5
0 -1
-1 -0.5 0 0.5 1 -10 -5 0 5 10
x 2/9-y 2/4=1
2 5
1.5
1 0
y
0.5
0 -5
1 2 3 4 5 -5 0 5
x