Jump to content
  • Revista PROGRAMAR: Já está disponível a edição #60 da revista programar. Faz já o download aqui!

Sign in to follow this  
explod1ng

Duvida Matlab

Recommended Posts

explod1ng

Considere o sinal de tempo discreto x[n] = 2sin[0.02π n](u[n + 50]− u[n − 50]) .

Determine e apresente a resposta dos seguintes sistemas ao sinal de entrada x[n], para −60 ≤ n ≤ 60 :

1y [n] = 0.1x[n −1]− 0.7x[n − 2]+ 0.2x[n − 4];

estou a tentar resolver este problema utilizando o matlab.

O codigo criado por mim foi o seguinte:

function ex4_1a( xs )

syms ns;

n=-60:60;

y=[];

x=[];

y2=0.1*subs(xs,ns,ns-1)-0.7*subs(xs,ns,ns-2)+0.2*subs(xs,ns,ns-4);

for k=1:length(n),

if n(k)<-50, y(k)=0; x(k)=0;

elseif n(k)>=50, y(k)=0; x(k)=0;

else y(k)=subs(y2,ns,k);x(k)=subs(xs, ns, k);

end;

end;

plot(n,x);

hold all;

plot(n,y);

legend(' x[n]=2sin[0.02*pi*n](u[n+50]-u(n-50))',' y[n]=0.1x[n-1]-0.7x[n-2]+0.2x[n-4]',2,'Location','NorthEast');

title('Resposta do sistema no intervalo [-60,60]');

Mas depois a tentar correr o programa introduzindo 2sin[0.02π n](u[n + 50]− u[n − 50]) como sendo uma string da o seguinte erro:

x='2*sin*[0.02*pi*n]*(u*[n+50]-u[n-50])'

x =

2*sin*[0.02*pi*n]*(u*[n+50]-u[n-50])

>> ex4_1a(x)

??? Conversion to double from sym is not possible.

Error in ==> ex4_1a at 13

else y(k)=subs(y2,ns,k);x(k)=subs(xs, ns, k);

Alguem me pode dizer de que maneira devo introduzir a funcao de entrada?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.