0% found this document useful (0 votes)
30 views12 pages

Práctica 1 Matlab

The document demonstrates various commands in MATLAB for performing operations on functions such as factorizing, simplifying, deriving, integrating, evaluating, solving equations, and plotting functions. It shows how to plot graphs of functions, plot multiple functions on the same graph, create 3D plots, plot bar graphs and mesh plots, and arrange multiple plots in subplots.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views12 pages

Práctica 1 Matlab

The document demonstrates various commands in MATLAB for performing operations on functions such as factorizing, simplifying, deriving, integrating, evaluating, solving equations, and plotting functions. It shows how to plot graphs of functions, plot multiple functions on the same graph, create 3D plots, plot bar graphs and mesh plots, and arrange multiple plots in subplots.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

JUAN JOSÉ CLAROS URIONA

TÓPICOS DE MATEMÁTICA PURA APLICADA (MATLAB)

>> syms x y z

>>f=x^3-x

f =x^3 – x

>>g=(x^2+3*x+2)/(x+2)

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

a) Factorizar f mediante comandos de MATLAB

>>rf=factor(f)
rf =x*(x - 1)*(x + 1)

b) Simplificar g, mediante comandos de MATLAB

>>rg=simplify(g)
rg =x + 1

c) Derivar f respecto de x, mediante comandos de MATLAB

>>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

e) Sustituir los valores x=1, y=2 en h, mediante comandos de MATLAB

>> rh=subs(h,{x,y},{1,2})
rh =9

f) Resolver la ecuación f(x)=0 mediante comandos de MATLAB

>> recf=solve(f,x)
recf =
0
1
-1

g) Resolver el sistema de ecuaciones mediante comandos de MATLAB

>> 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;

>> plot(x,y),title('grafico 1'),grid,xlabel('eje x'),text(0,0,'0'),axis([-3,3,-1,3])

>>

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;

>> plot(x,y),title('grafico 1'),grid,xlabel('eje x'),text(0,0,'0'),axis([-3,3,-1,3])

>> plot(x,y),title('grafico 1'),grid,xlabel('eje x'),text(0,0,'0'),axis([-3,3,-1,3])


grafico 1
3

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 -1.8 -1.6 -1.4 -1.2 -1 -0.8 -0.6 -0.4 -0.2 0
>> ezplot('x^2+y^2=4',[-3,3])

x 2+y 2=4
3

0
y

-1

-2

-3
-3 -2 -1 0 1 2 3
x

>> ezplot('x^2+y^2=4',[-3,3]),grid

x 2+y 2=4
3

0
y

-1

-2

-3
-3 -2 -1 0 1 2 3
x
x1=-3:0.1:3;

>> y1=x1.^2-1;

>> plot(x1,y1)

-1
-3 -2 -1 0 1 2 3

x1=-3:0.1:3;

>> y1=x1.^2-1;

>> plot(x1,y1)

>> hold on

>> x2=-pi:0.1:pi;

>> y2=cos(x2);

>> plot(x2,y2)

-1
-4 -3 -2 -1 0 1 2 3 4
>> x=-2:0.01;2;

>> y=x.^2;

>> bar(x,y)

3.5

2.5

1.5

0.5

0
-2 -1 0

x=-2:0.01;2;

>> y=x.^2;

>> bar(x,y)

>> area(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
x1=-2:0.1:2;

>> y1=x1.^3-1;

>> bar(x1,y1)

-2

-4

-6

-8

-10
-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5

x1=-2:0.1:2;

>> y1=x1.^3-1;

>> bar(x1,y1)

>> area(x1,y1)

-2

-4

-6

-8

-10
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
t=-1:0.1:1;

>> x=2*t;

>> y=t.^2;

>> plot(x,y)

0.9

0.8

0.7

0.6

0.5

0.4

0.3

0.2

0.1

0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2

>> t=-10*pi:0.1:10*pi;

>> x=cos(t);

>> y=sin(t);

>> z=t;

>> plot3(x,y,z)

40

20

-20

-40
1
0.5 1
0 0.5
0
-0.5 -0.5
-1 -1
x=-10:0.1:10;

>> y=-10:0.1:10;

>> [X,Y]=meshgrid(x,y);

>> Z=sin(sqrt(X.^2+Y.^2));

>> mesh(X,Y,Z)

x1=-1:0.1:1;

>> y1=abs(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

You might also like