Waves mode summation for a string
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I required to computer code for mode summation for a string with a length of 20, wave velocity of 3.
Here is my attempt:
clear all
clc
xs=8; % source position
v=3; % wave velocity
L=20; % length of string
ta=0.2; % tension of string
n=20; % number of nodes (we need to perform the summition for first 40 and 80 nodes.
% here i fixed the nodes for the seek of simplicity)
t=1; % time after the spring plucked,
omga=n*pi*v/L; % input source factor
F=exp(-((omga*ta).^2)/4); % force
x=0:0.01:20; % waves amplitude for distnace vary form 0 to 20
%x=x';
for i=1:length(x)
u(i)=sin(n*pi*xs/L)*F*sin(n*pi*x(i)/L)*cos(omga*t);
end
plot(x,u)
The above script produce this plot for n=20
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/868905/image.png)
This script works perfectly to generate the wave for a single node value (above figure). I required to generate the waves for node values varies between 1 to 40. For this i modifiy teh script as follows:
clear all
clc
xs=8;
v=3;
L=20;
ta=0.2;
t=1;
n=1:1:40;
x=0:0.1:20;
for j=1:length(n)
omga(j)=n(j)*pi*v/L;
F(j)=exp(-((n(j)*pi*v*ta).^2)/4);
for i=1:length(x)
u(i)=sin(n(j)*pi*xs/L)*F(j)*sin(n(j)*pi*x(i)/L)*cos(omga(j)*t);
end
end
plot(x,u)
This output produce a single line where i required to plot all (x,u) for n=1:40. along with a summiation plot of all the waves nodes (bold one in the attched figure) ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/868910/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/868910/image.png)
0 comentarios
Respuesta aceptada
KSSV
el 21 de En. de 2022
xs=8;
v=3;
L=20;
ta=0.2;
t=1;
n=1:1:40;
x=0:0.1:20;
omga = zeros(1,length(n)) ;
F = zeros(1,length(n)) ;
u = zeros(length(n),length(x)) ;
for j=1:length(n)
omga(j)=n(j)*pi*v/L;
F(j)=exp(-((n(j)*pi*v*ta).^2)/4);
u(j,:)=sin(n(j)*pi*xs/L)*F(j)*sin(n(j)*pi*x/L)*cos(omga(j)*t); % no loop needed
end
us = sum(u) ;
plot(x,us)
2 comentarios
KSSV
el 21 de En. de 2022
The code given by you is edited to get the sum. It is your job to check what you have missed in the code. The other mode number values are very less. You have to check your formula and the constant values given.
Más respuestas (0)
Ver también
Categorías
Más información sobre Control System Toolbox en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!