Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Plotting Amplitude and Phase spectrum .... (Help needed)

Subject: Plotting Amplitude and Phase spectrum .... (Help needed)

From: Animesh Pandey

Date: 1 Apr, 2011 13:43:04

Message: 1 of 1

clc
syms an bn a0;
syms t n;
syms x;

T = input('Enter the Time Period: ');
N = input('Enter the number of terms: ');
x = input('Enter the function: ');
f = @(t) x;

an = int(f(t).*cos(n*pi*t/T),t,-T,T)*(1/T);
bn = int(f(t).*sin(n*pi*t/T),t,-T,T)*(1/T);
a0 = int(f(t),t,-T,T)*(1/T);
y = a0;

pretty(a0);
pretty(an);
pretty(bn);

for i=1:1:N;
     y = y + subs(an, i).*cos(2*pi*i*t/T) + subs(bn, i).*sin(2*pi*i*t/T);
end

y

t=-5 : 0.01 : 5 ;
er=eval(y);
plot(t, er), grid;


This is a program to plot Fourier series of any function using Symbolic Maths Toolbox.
I want to plot the Amplitude spectrum and Phase spectrum of the functions ...... how can I do that ????
Please help !
Thanks .... !!! :)

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us