Sound from a plucked string

Can anyone debug this program for me?? I will be very grateful to you.
l = 0.6;
x = 0.3*l; % pluck position is 30% of total length
xp = x ; %pickup point same as pluck position
u = 1:100;
Ts = 60.97;
T = 1/8000;
I = 1.71e-13;
E = 7.4000e+9;
rho = 1140;
A = 5.188e-7;
d1 = 8.0e-005;
d3 = -1.4e-005;
stl = (u.*pi/l);
e1 = d1-(d3*(stl.^2));
e2 = (E*I*(stl.^4))+(Ts*(stl.^2));
Kux = sin(stl*x);
Nu = l/2;
den = rho*A;
Wu = (stl.^4*((E*I/den)-(d3^2/(2*den)^2)))+
(stl.^2*((Ts/den)+((d1*d3)/2*(den^2))))-(d1^2/(4*(den^2)));
Wu = sqrt(Wu);
sg = (-d1+(d3*(stl.^2)))/(2*den);
b0= 1/den;
b1= (b0*sin(Wu.*T))./(Wu);
c1 = -2*exp(sg.*T).*cos(Wu*T);
c0 = exp(2*sg*T);
% from Fe_mu.m :
m = 100;
u = 1:100;
x = 0.3;
xp = x;
% ******* recursive system implementation ******
for n = 1:1:m;
Ge(n) = dfilt.df1([0 b1(n)],[1 c1(n) c0(n)]); % Discrete Filter Ge^d(mu,z)
a(n) = dfilt.scalar((fe1_mu(n)*Kux(n))/Nu); % Gain factor
a(mu,xp)
hd(n) = cascade(Ge(n),a(n)); % series connection of Ge^d and a
end
H =
dfilt.parallel(hd(1),hd(2),hd(3),hd(4),hd(5),hd(6),hd(7),hd(8),hd(
9),hd(10),hd(11),hd(12),hd(13),hd(14),hd(15),hd(16),hd(17),hd(18),
hd(19),hd(20)...,hd(100)));
% display response of system
fe2k=[1 ; zeros(10000,1)];
g=conv(impz(H),fe2k); %convolution with fe^d_2(kT)
fvtool (g)
sound(g)

2 件のコメント

Wayne King
Wayne King 2011 年 11 月 2 日
please format your code
Avishek
Avishek 2011 年 11 月 2 日
can i send you the M file??

サインインしてコメントする。

 採用された回答

Walter Roberson
Walter Roberson 2011 年 11 月 2 日

0 投票

There are two possibilities. I suspect the easier one will not work, but it is easier:
1) Change the line
dfilt.parallel(hd(1),hd(2),hd(3),hd(4),hd(5),hd(6),hd(7),hd(8),hd(
9),hd(10),hd(11),hd(12),hd(13),hd(14),hd(15),hd(16),hd(17),hd(18),
hd(19),hd(20)...,hd(100)));
to
dfilt.parallel(hd(1),hd(2),hd(3),hd(4),hd(5),hd(6),hd(7),hd(8),hd(
9),hd(10),hd(11),hd(12),hd(13),hd(14),hd(15),hd(16),hd(17),hd(18),
hd(19),hd(20),...
hd(100)));
But I suspect that will not work in practice.
2)
Change the line
hd(n) = cascade(Ge(n),a(n)); % series connection of Ge^d and a
to
hd{n} = cascade(Ge(n),a(n)); % series connection of Ge^d and a
and change the line
dfilt.parallel(hd(1),hd(2),hd(3),hd(4),hd(5),hd(6),hd(7),hd(8),hd(
9),hd(10),hd(11),hd(12),hd(13),hd(14),hd(15),hd(16),hd(17),hd(18),
hd(19),hd(20)...,hd(100)));
to
dfilt.parallel(hd{:});
I believe this is the solution you need.

8 件のコメント

Avishek
Avishek 2011 年 11 月 3 日
Thanks very much for answering. But now am getting problem with this line
:"a(n) = dfilt.scalar((fe1_mu(n)*Kux(n))/Nu); % Gain factor"
Walter Roberson
Walter Roberson 2011 年 11 月 3 日
What error message are you seeing?
Avishek
Avishek 2011 年 11 月 5 日
It says "??? Undefined function or method 'fe1_mu' for input arguments of
type 'double'."
I don't have any file named fe1_mu but its named Fe_mu.m and it is not a function m-file.
I'm posting the other file below. Please look into it. I'l be grateful.
Avishek
Avishek 2011 年 11 月 5 日
% Sturm Liouville Transformation of fe(x)
% Calculates fourier coefficients of fe(x)
l=0.6; % length of string
d=0.02; % deflection in metres (2cm)
xp= 0.3*l; % pluck position is 30% of total length
syms x xp %stl m1 m2 c defined as symbols for integration
m1= d/xp; % gradient of first part
m2= d/((xp)-l); % gradient of second part
c = d+((d*xp)/(l-xp));
u= 1:100;
%***********************************************
stl= (u*pi/l);
Kux= sin(stl*x); %sturm liouville kernel
%***********************************************
fe1 = m1*x;
fe2 =(m2*x)+c;
fe1= fe1*Kux ; %multiply with kernel
fe2= fe2*Kux ;
femu1= int(fe1,x,0,xp) ; %integration for increasing fe(x) stl transformation
femu2= int(fe2,x,xp,l) ; %integration for decreasing fe(x) stl transformation
fe1_mu = femu1+femu2 ; %sturm liouville trans. of fe(x)
Walter Roberson
Walter Roberson 2011 年 11 月 5 日
At the top of the first set of code, insert the statement
Fe_mu
(just the name of the script.)
This will cause a number of variables to be initialized, including fe1_mu
Avishek
Avishek 2011 年 11 月 5 日
In which one?? First one which contains the digital filters??
Walter Roberson
Walter Roberson 2011 年 11 月 5 日
Yes, that one -- put the Fe_mu invocation at the top of the routine that needs to use the value of the fe1_mu variable.
Avishek
Avishek 2011 年 11 月 6 日
Thank you very much sir!!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeAudio Processing Algorithm Design についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by