Waves mode summation for a string

4 次查看(过去 30 天)
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
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)

采纳的回答

KSSV
KSSV 2022-1-21
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 个评论
Andi
Andi 2022-1-21
The output (attached figure) of your proposed script is only valid for n=1.
Where the required output should be like this:
KSSV
KSSV 2022-1-21
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Control System Toolbox 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by