You are on page 1of 16

1

>> G(s)=[5(s+4)]/[(s+2+4j)(s+2-4j)]

??? G(s)=[5(s+4)]/[(s+2+4j)(s+2-4j)]

Error: Unbalanced or unexpected parenthesis or bracket.

>> num=[5 20];

>> den=[1 4 20];

>> [z,p,k]=tf2zp(num,den)

z=

-4

p=

-2.0000 + 4.0000i

-2.0000 - 4.0000i

k=

>> [num,den]=zp2tf(z,p,k)

num =

0 5 20
den =

1 4 20

>> G=tf(num,den);

>> G=zpk(z,p,k)

Zero/pole/gain:

5 (s+4)

---------------

(s^2 + 4s + 20)

>> P=s^4+4s^3+4s^2+s+20

??? P=s^4+4s^3+4s^2+s+20

Error: Unexpected MATLAB expression.

>> p=[1 4 4 1 20];

>> r=roots(p)

r=

-2.6545 + 1.2595i

-2.6545 - 1.2595i

0.6545 + 1.3742i

0.6545 - 1.3742i

>> r=roots([1 4 4 1 20])

r=
-2.6545 + 1.2595i

-2.6545 - 1.2595i

0.6545 + 1.3742i

0.6545 - 1.3742i

>> Y(s)=1/(s+a)(s+b);

??? Y(s)=1/(s+a)(s+b);

Error: Unbalanced or unexpected parenthesis or bracket.

>> a=1,b=2

a=

b=

>> Y(t)=e^(-t)-e^(-2t)

??? Y(t)=e^(-t)-e^(-2t)

Error: Unexpected MATLAB expression.

>> num=1;

>> den=[1 3 2];

>> impulse(num,den)
>> num=1;

>> den=[1 3 2];

>> t=0:0.1:12;

>> impulse(num,den,t)
>> G(s)=Y(s)/R(s)=4/s^2+0.8s+4

??? G(s)=Y(s)/R(s)=4/s^2+0.8s+4

Error: The expression to the left of the equals sign is not a valid target for an assignment.

>> num=4;

>> den=[1 0.8 4];

>> step(num,den)

1.1

>> x=linspace(0,4*pi,60);

>> y=sin(x);

>> figure(1)

>> plot(x,y)

>> z=cos(x);

>> figure(2)

>> plot(x,z,x,y)

>> figura(3)
??? Undefined function or method 'figura' for input arguments of type 'double'.

>> plot(x,y,x,y,'*')

>> figure(4)

>> plot(y,z)

>> figure(5)

>> plot(x,y,x,2*y.*z,'--')

>> grid

>> xlabel

??? Error using ==> xlabel at 17

Not enough input arguments.

>> ylabel

??? Error using ==> ylabel at 17

Not enough input arguments.

>> litle('2sen(x)cos(x)sen(2x')

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

>> figure(6)

>> plot3(y,z,x),grid
2.2 >> x=linspace(0,16,100);

>> y=sin(x);

>> z=(y>=0).*y;

>> z=z+0.5*(y<0);

>> z=(x<=14).*z;

>> plot(x,z)

>> xlabel('x'),ylabel('z=f(x)')

>> title('señal discontinua')


2.3

>> x=linspace(0,6*pi,60);

>> y=sin(x);

>> z=cos(x);

>> plot(x,y)

>> hold on

>> plot(x,z,'m')

>> hold off

>>

2.4

>> x=linspace(0,4*pi,60);

>> y=sin(x);

>> z=cos(x);

>> a=2*sin(x).*cos(x);

>> b=sin(x)./(cos(x)+eps);

>> subplot(2,2,1)

>> plot(x,y),axis ([0 4*pi -1 1]), title('sin(x)')

>> subplot(2,2,2)

>> plot(x,y),axis ([0 4*pi -1 1]), title('cos(x)')


>> subplot(2,2,3)

>> plot(x,a),axis ([0 4*pi -1 1]), title('2sin(x)cos(x)')

>> subplot(2,2,4)

>> plot(x,b),axis ([0 4*pi -40 40]), title('tg=sin(x)/cos(x)')

2.5

>> M=7;

>> N=2^M

N=

128

>> n=0:1:N-1;

>> To=1;

>> T=10;

>> dt=T/N;

>> t=n*dt;

>> w=zeros(1,length(t));

>> for i=1:length(w)


if t(i)<To

w(i)=1;

end

end

>> W=dt*fft(w);

>> f=n/T;

>> pos=find(f>=4/To);

>> if~isempti(pos)&(pos(1))<=N/2)

??? if~isempti(pos)&(pos(1))<=N/2)

Error: Unbalanced or unexpected parenthesis or bracket.

>> pos=pos(1);

>> else

??? else

Error: Illegal use of reserved keyword "else".

>> pos=floor(length(f)/2);

>> end

??? end

Error: Illegal use of reserved keyword "end".

>> subplot(3,1,1)

>> plot(t,w);

>> title

??? Error using ==> title at 18

Not enough input arguments.

>> title ('Forma de onda en el tiempo')


>> xlabel('w(t)')

>> xlabel('Tiempo (s)')

>> ylabel('w(t)')

>> subplot(3,1,2)

>> plot(f(1:pos),abs(W(1:pos)));

>> title('ESPECTRO DE MAGNITUD HASTA 4o NULO')

>> xlabel('Frecuencia (Hz)')

>> ylabel('|W(f)|')

>> subplot(3,1,3)

>> plot(f(1:pos),(180/pi)*angle(W(1:pos)));

>> grid

>> title('ESPECTRO DE FASE HASTA 4o NULO')

>> xlabel('Frecuencia (Hz)')

>> ylabel('\theta(f)(grados)')

Tema2 prob 3

>> Fs=100;

>> t=(-100:100)/Fs;

>> w=2*pi;

>> A=2;
>> f=0

f=

>> for n=1:1000;

f=f+(4*A/(n*pi))*(sin(n*0.5*pi))*cos(n*w*t);

end

>> end;

??? end;

Error: Illegal use of reserved keyword "end".

>> plot(t,f)

>> xlabel('t(seg)')

>> ylabel('AMPLITUD')

>> title('FUNCION PAR ONDA CUADRADA')

>> gris

??? Undefined function or variable 'gris'.


Tema 3 prob 1

>> N=128;

>> t=linspace(0,3,N);

>> f=2*exp(-20*t);

>> figure(1)

>> plot(t,f)

>> xlabel('Time,seg'),ylabel('f(t)'),grid

>> axis([0 0.3 0 2]);

>> Ts=2*pi/Ts;

??? Undefined function or variable 'Ts'.

>> Ts=t(2)-t(1);

>> Ws=2pi/Ts;

??? Ws=2pi/Ts;

Error: Unexpected MATLAB expression.

>> F=fft(f);

>> Fp=F(1:N/2+1)*Ts;

>> W=Ws*(0:N/2)/N;

??? Undefined function or variable 'Ws'.

>> figure(2)

>> plot(W,abs(Fp),'+')

??? Undefined function or variable 'W'.

>> xlabel('Frequency,Rad/s'),ylabel('|F(W)|')

>> N=128;

>> t=linspace(0,3,N);

>> Ts=t(2)-t(1);
>> Ws=2pi/Ts;

??? Ws=2pi/Ts;

Error: Unexpected MATLAB expression.

>> W=Ws*(0:N/2)/N;

??? Undefined function or variable 'Ws'.

>> Fa=2./(20+j*W);

??? Undefined function or variable 'W'.

>> figure(3)

>> plot(W,abs(Fa))

??? Undefined function or variable 'W'.

>> xlabel('Frequency,Rad/s'),ylabel('|F(W)|')

You might also like