Hey guys .. I'm new with Matlab , and I have to submit the homework to my instructor due tomorrow so I need your help please! I want to know what's wrong with this code .. it doesn't give an error message but the figure window doesn't show the graph ! it's for finding the magnitude and phase response for this function y=(10 sin (100t)) / (2 pi t) fs=70000; t=0:1/fs:0.5; Y=(5*sin(700*t))/(pi*t); N=length(Y); Yf=fft(Y); Ym=abs(Yf); Ym=Ym(1:N/2); Yp=angle(Yf); F=(0:N/2-1)*(fs/N); plot(F,Ym); xlabel('Frequency in HZ'); Ylabel('Amplitude'); title('Frequency response for sin wave');
Your problem is in: Y=(5*sin(700*t))/(pi*t); This is a scalar division and the result is a single value. For a vector division use: Y=(5*sin(700*t))./(pi*t);
Thank you but the problem isn't solved yet .. No results !! :/ oh BTW it's Y=(5*sin(100*t))./(pi*t); not Y=(5*sin(700*t))./(pi*t); my bad !
I believe you need the"figure(1)" line in there, though I haven't used it in a while. If that doesn't work, just use the bode()