# Matlab project

Discussion in 'Programmer's Corner' started by teen devil, Apr 13, 2010.

1. ### teen devil Thread Starter Active Member

Apr 6, 2009
47
0
Hey guys i am new to matlab and signal processing i need to submit a project regarding any of the following topics
1.convolution
2.fourier series and transform
3.correlation
4.working with a simple audio signal

2. ### R!f@@ AAC Fanatic!

Apr 2, 2009
8,792
771
we don't have any ideas buddy.
Ur project, so you have to come up with something and then we will discuss about it.
So post ur project, explain it and if you are having trouble, we will help.

3. ### johndoe45 Member

Jan 30, 2010
364
1
what can do is look at fourier series and transforms online. there should be some code out. i know one of mathematica that my friend used the other day. works in matlab too. at least it should. was pretty awesome. the plot function was inside the loop. so the graph changed its shape through each iteration or whatever you call it. so check it out and modify it to fit your project. good luck

Last edited: Apr 14, 2010
4. ### teen devil Thread Starter Active Member

Apr 6, 2009
47
0
jhon... i am not getting u if i put the plot command in loop .. for example i am right shifting the signal by using loop will it show it moving in the final plotting figure???

5. ### johndoe45 Member

Jan 30, 2010
364
1
i don't know how to explain it. i was going to ask him for the code today but forgot. like i'm guessing a fourier transform calculates n=1, then n=2, ....to n=whatever you specify. and if you plot the function in the loop. the plot updates everytime it calculates the new n. so the graph is moving since it is in the loop.

6. ### teen devil Thread Starter Active Member

Apr 6, 2009
47
0
by bad luck jhon i hv to submit the project by tomorrow... damn

7. ### johndoe45 Member

Jan 30, 2010
364
1
i got it from him. hopefully you log on since it is due tomorrow

% Example MATLAB M-file that plots a Fourier series

% Set up some input values.
L = 3 % period = 2*L
Num_Terms = 100 % Approximate infinite series with Num_Terms terms

% Miscellaneous setup stuff
format compact; % Gets rid of extra lines in output. Optional.

% Initialize x axis values from -L to +L. Middle number is step size.
% Make middle number smaller for smoother plots.
x = -L:0.001:L;

% Initialize y-axis values: y = f(x)
f = zeros(size(x));

a0 = 1/6;
f = f + a0;

% Loop Num_Terms times through Fourier series, accumulating into f.
for n=1:Num_Terms

n

% Formula for an. It is safer to use lots of parentheses,
% just in case, to make sure things are executed in the order
% that they should be. For example, 2/n*pi is interpreted
% as (2/n)*pi, which is not what I want. Better to write
% (2/(n*pi)) and make sure.
an = (2/(n*pi))*sin(n*pi/L) + (6/(n^2*pi^2))*( cos(n*pi/L) -1 );

% Formula for bn.
bn = 0;

% Add cosine and sine into f.
f = f + an*cos(n*pi*x/L) + bn*sin(n*pi*x/L);

% Plot intermediate f. You can comment these three lines out for
% faster execution speed. The function pause(n) will pause for
% about n seconds. You can raise or lower for faster plots.
plot(x,f)
grid;
pause(0.1);

end;

8. ### teen devil Thread Starter Active Member

Apr 6, 2009
47
0
thnx jhon for ur help........

Jan 30, 2010
364
1