0% found this document useful (0 votes)
22K views10 pages

Practicas Lab

The document contains code for performing various operations in MATLAB such as defining matrices and vectors, performing arithmetic operations on matrices and vectors, finding roots of polynomials, convolutions, plotting functions, and using subplot to display multiple plots. Key operations include defining matrices A, B, C, and vectors D, P, Q, r, s, finding the roots of polynomial r, convolving vectors v1 and v2, plotting a damped sine wave, and using subplot to display 4 plots of different exponential functions in a 2x2 grid.

Uploaded by

juan_pcn
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)
22K views10 pages

Practicas Lab

The document contains code for performing various operations in MATLAB such as defining matrices and vectors, performing arithmetic operations on matrices and vectors, finding roots of polynomials, convolutions, plotting functions, and using subplot to display multiple plots. Key operations include defining matrices A, B, C, and vectors D, P, Q, r, s, finding the roots of polynomial r, convolving vectors v1 and v2, plotting a damped sine wave, and using subplot to display 4 plots of different exponential functions in a 2x2 grid.

Uploaded by

juan_pcn
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/ 10

Practica 1

Control Moderno
Geovanny Dutn
>> clear
>> A={1 2 3;3 4 5;6 7 8}

A=

[1]

[2]

[3]

[3]

[4]

[5]

[6]

[7]

[8]

>> B={4 5 6;7 8 7}

B=

[4]

[5]

[6]

[7]

[8]

[7]

>> C={7 4 1}
C=

[7]

[4]

[1]

>> D={4; 7; 7}

D=

[4]
[7]
[7]

>> a=1; b=2; c=3

c=

>> a=1; b=2; c=3;


>> x1= (-b+(sqrt((b^2-4*a*c))/(2^a)
??? x1= (-b+(sqrt((b^2-4*a*c))/(2^a)
|
Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.

>> x1= (-b+(sqrt((b^2)-(4*a*c))/(2^a)


??? x1= (-b+(sqrt((b^2)-(4*a*c))/(2^a)
|
Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.

>> x1= (-b+(sqrt((b^2)-(4*a*c)))/(2^a)


??? x1= (-b+(sqrt((b^2)-(4*a*c)))/(2^a)
|

Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.

>> x1= (-b+(sqrt((b^2))-(4*a*c)))/(2*a)

x1 =

-6

>> P={2 7 1}

P=

[2]

[7]

[1]

>> Q={1 0 4 0}

Q=

[1]

[0]

[4]

>>

x=3;
>> P={3 5 2 4};
>> polyval(p,x)
>> P=[3 5 2 4];
>> polyval(P,x)

[0]

ans =
136
>> r=[2 5 9 7]
r=
2

>> roots(r)
ans =
-0.6550 + 1.5850i
-0.6550 - 1.5850i
-1.1900

>> s=[4 6 9 1]
s=
4

>> poly(s)
ans =
1 -20 133 -330 216

>> P2=[1 -2 1]; P1=[1 1];


>> conv(P2,P1)
ans =
1

-1

-1

>> [a,b]=deconv(P2,P1)
a=
1

-3

b=
0

t=[0: 0.5: 4]
t=
0
4.0000

0.5000

1.0000

1.5000

>> % escalar por vector


>> k=15; v1=[2 5 8]; v2=[7 4 1];
>> k*v1
ans =
30

75 120

>> v1+v2
ans =
9

>> v1*v2
>> v1.*v2
ans =
14

20

>> k*v2
ans =
105

60

15

>> conv(v1,v2)
ans =
14

43

78

37

37

>> conv(v2,v1)
ans =
14

43

78

2.0000

2.5000

3.0000

3.5000

>> t=[0:0.1:10];
>> y=10-exp(-t).*sin(5*t);
>> plot(t,y)
>> plot(t,y);
>>
>> plot(t,y)
>> xlaberl('tiempo(s)')
??? Undefined function or method 'xlaberl' for input arguments of type 'char'.

>> xlaberl('tiempo(s)')
??? Undefined function or method 'xlaberl' for input arguments of type 'char'.

>> plot(t,y)
>> plot(t,y)
>> y=10-exp(-t).*sin(5*t);
>> t=[0:0.1:10];
>> y=10-exp(-t).*sin(5*t);
>> plot(t,y)
>> xlaberl('tiempo(s)')
??? Undefined function or method 'xlaberl' for input arguments of type 'char'.

>> xlabel('tiempo(s)')
>> ylabel('y(t)')
>> ytitle('senoide amortiuguada
??? ytitle('senoide amortiuguada
|
Error: A MATLAB string constant is not terminated properly.

>> ytitle('senoide amortiuguada')


??? Undefined function or method 'ytitle' for input arguments of type 'char'.

>> title('senoide amortiuguada')


>> plot(t,r)
??? Undefined function or variable 'r'.

>> plot(t,r,'r')
??? Undefined function or variable 'r'.

>> plot(t,y,'r')
>> grid
>>

>> fplot('10*exp(-t).*sin(5*t)',[0,10])
>> grid%activa la rejilla
>> xlabel('tiempo(s)')%etiqueta eje x
>> ylabel('y(t)')%etiqueta eje y
>> title('Senoide Amortiguada')%titulo
>> plot(t,y,'r +')

t=[0:pi/180:4*pi];%intervalo representacin
>> y1=sin(t);
>> y2=cos(t);
>> plot(t, y1, 'r o', t, y2, 'g-')

t=0:0.1:10;
>> subplot(2,2,1)%primera subventana de matriz
>> y1=exp(-t);
>> plot(t,y1)
>> subplot(2,2,2)%primera subventana de matriz
>> y2=t.*exp(-t);
>> plot(t,y2)
>> subplot(2,2,3)%primera subventana de matriz
>> y3=exp(-t).*cos(t);
>> plot(t,y3)
>> subplot(2,2,4)%primera subventana de matriz
>> y4=exp(t).*cos(t);
>> plot(t,y4)

You might also like