Wavplay

조회 수: 5 (최근 30일)
Vagelis Kounis
Vagelis Kounis 2011년 4월 4일
댓글: mariam sleiman 2019년 1월 4일
I have created a .m file that includes a Fourier transformation of a square wave function without the use of the fft or any other matlab expression. Now i want to listen to the created function using wavplay but i can't. It seems that i have to build a matrix but the problem is that i used syms for my variable and therefore my function is symbolic and not a matrix of numbers.. Can anyone help me? I have tried to convert from syms t to t=1:.1:100 but then i get an error that matrix dimensions don't agree.. here is my code:
syms t
T=pi;
N=15;
for n=1:2:N
y(n)=4/pi*1/n*sin(2*pi*n*t/T);
end
palmos=sum(y);
ezplot(palmos)
axis([0 2*T -1.5 1.5])

답변 (1개)

Jarrod Rivituso
Jarrod Rivituso 2011년 4월 5일
When you switch t to being a vector, you can't store an entire vector into a single basic element y(n). You could do this in a single cell with y{n}, but since you are just summing it later, you could also perform the sum within the loop.
Here is how I'd change your code. Note I made a few other adjustments too, namely a higher sampling frequency and shorter vector.
fs = 8000;
t = 0:1/fs:10;
T = pi;
N = 15;
y = zeros(size(t));
for n = 1:2:N
y = y + (4/pi)*(1/n)*sin(2*pi*n*t/T);
end
plot(t,y);
wavplay(y,fs);
  댓글 수: 1
mariam sleiman
mariam sleiman 2019년 1월 4일
please can usend me wavplay.m function becouse i work ondenoising a speech an need this func.,thank u. regards

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by