Matlab code

Discussion in 'Homework Help' started by salam, Oct 29, 2012.

  1. salam

    Thread Starter New Member

    Oct 29, 2012
    3
    0
    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');
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,368
    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);
     
    salam likes this.
  3. salam

    Thread Starter New Member

    Oct 29, 2012
    3
    0
    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 !
     
  4. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    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()
     
    salam likes this.
Loading...