How to link the wave equation with guitar string
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am totally a new user of Matlab, and my final year project is requested to use Matlab, so I really need your help to answer my questions...thanks a lot!
dx = .01 ; % Spacing of points on string dt =.01 ; % Size of time step
c = 1 ;% Speed of wave propagation
L = 1 ;% Length of string
stopTime = 30 ; % Time to run the simulation
r = c*dt/dx ;
n=L/dx+1
% Set current and past to the graph of a plucked string
current = .5-.5* cos (2* pi /L * [ 0 : dx :L ] ) ;
past = current ;
for t=0: dt : stopTime
% Calculate the future position of the string
future ( 1 ) = 0 ;
future ( 2 : n-1) = r^2*( current ( 1 : n-2)+current ( 3 : n ) ) + 2*(1-r^2)* current ( 2 : n-1) - past ( 2 : n-1);
future (n) = 0 ;
% Set things up for the next time step
past = current ;
current = future ;
% Plot the graph after every 10th frame
if mod( t /dt , 10) == 0
plot ( [ 0 : dx :L] , current )
axis ( [ 0 L -2 2 ] )
pause ( .001 )
end
end
The above code i get from website and anyone can explain to me how to link this code with wave equation and guitar string (fixed at both ends)?
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Audio I/O and Waveform Generation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!