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 Center および File ExchangeFourier Analysis and Filtering についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by