magnitude and phase response

17 views (last 30 days)
pinna Afff
pinna Afff on 10 Dec 2011
i have to plot magnitude and phase response of a real time signal
my code:
t = linspace(0,1,1000); A = 10; f = 5; phi = pi/4;
sig = A*sin(2*pi*f*t + phi); plot(t , sig)
res = fft(sig); plot(t,res) res1 = abs(sig); plot(t,res1)
i am confused in fft part, or suggest me other commands through which i can find magnitude and phase

Answers (2)

Daniel Shub
Daniel Shub on 10 Dec 2011
Maybe I am missing something, but isn't the magnitude A and the phase phi?
  1 Comment
pinna Afff
pinna Afff on 10 Dec 2011
i have to plot magnitude and phase response of this sinosoidal

Sign in to comment.


Greg Heath
Greg Heath on 12 Dec 2011
N = 1000, tmax = 1, dt = tmax/(N-1), Fs = 1/dt, T = N*dt
t = linspace(0,tmax,N);
t = dt*linspace(0,N-1,N);
t = linspace(0,T-dt,N);
A = 10; f0 = 5; phi = pi/4;
sig = A*cos(2*pi*f0*t + phi); % NOTE: cos, NOT sin
figure(1); plot(t , sig)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
df = Fs/N, fmax = (N-1)*df
f = linspace(0,fmax,N);
f = df*linspace(0,N-1,N);
f = linspace(0,Fs-df,N);
SIG = fft(sig); absSIG = abs(SIG); phaseSIG = angle(SIG); figure(2), t(t,res) rsees1 = abs(sig); plot(t,res1)
  1 Comment
Greg Heath
Greg Heath on 12 Dec 2011
Delete:
t(t,res) rsees1 = abs(sig); plot(t,res1)

Sign in to comment.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!