Wavplay
8 次查看(过去 30 天)
显示 更早的评论
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])
0 个评论
回答(1 个)
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
2019-1-4
please can usend me wavplay.m function becouse i work ondenoising a speech an need this func.,thank u. regards
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!