trying to align multiple sin waves onto same graph with the period of the wave on the x axis.

조회 수: 2 (최근 30일)
I'm trying to align sin waves in the format shown below.
with the matlab code i have at the moment, the graph output is as shown,
here is my current matlab code:
close all;
clear all;
g = 9.807;
T = 11;
H = 4;
d = 30;
CD = 0.85;
CM = 1.77;
Rho = 1025;
D = 1;
u = 1.142397329;
k = 0.033268881;
af = 0.571198664;
T2= 7;
H2= 2;
T3= 20;
H3= 5;
af2 = 0.897598;
k2 = 0.082154;
af3 = 0.314159265;
k3 = 0.010063836;
t = (0:0.1:22);
y = ((-1*CM*Rho*pi*D*D*af*af*H)/(8*k)).*sin(af*t);
plot(t,y)
hold on;
t2 = (0:0.1:14);
x = ((-1*CM*Rho*pi*D*D*af2*af2*H2)/(8*k2)).*sin(af2*t2);
plot (t2,x)
hold on;
t3 = (0:0.1:40);
z = ((-1*CM*Rho*pi*D*D*af3*af3*H3)/(8*k3)).*sin(af3*t3);
Can anyone explain how to align these waves?
Cheers.

답변 (2개)

KSSV
KSSV 2023년 3월 1일
Take same time array for all the waves.
g = 9.807;
T = 11;
H = 4;
d = 30;
CD = 0.85;
CM = 1.77;
Rho = 1025;
D = 1;
u = 1.142397329;
k = 0.033268881;
af = 0.571198664;
T2= 7;
H2= 2;
T3= 20;
H3= 5;
af2 = 0.897598;
k2 = 0.082154;
af3 = 0.314159265;
k3 = 0.010063836;
t = (0:0.1:22);
y = ((-1*CM*Rho*pi*D*D*af*af*H)/(8*k)).*sin(af*t);
plot(t,y)
hold on;
% t2 = (0:0.1:14);
t2 = t ;
x = ((-1*CM*Rho*pi*D*D*af2*af2*H2)/(8*k2)).*sin(af2*t2);
plot (t2,x)
hold on;
t3 = (0:0.1:40);
z = ((-1*CM*Rho*pi*D*D*af3*af3*H3)/(8*k3)).*sin(af3*t3);

Pratheek
Pratheek 2023년 3월 2일
To align the sine waves in the requested format, their time periods must always be the same. This means that only the amplitude of the wave should change in all three cases. However, in the equations provided, the time period of each wave is different, preventing them from being aligned. To achieve the same time period for all three waves, the equation "af*t=af2*t2=af3*t3" must be maintained. There are two ways to achieve this: either calculate the values of t, t2, and t3 to satisfy the equation, or use the same time period (af*t, af2*t2, or af3*t3) for all the waves.
close all;
clear all;
g = 9.807;
T = 11;
H = 4;
d = 30;
CD = 0.85;
CM = 1.77;
Rho = 1025;
D = 1;
u = 1.142397329;
k = 0.033268881;
af = 0.571198664;
T2= 7;
H2= 2;
T3= 20;
H3= 5;
af2 = 0.897598;
k2 = 0.082154;
af3 = 0.314159265;
k3 = 0.010063836;
t = (0:0.1:22);
t2 = (0:0.1:14);
t3 = (0:0.1:40);
y = ((-1*CM*Rho*pi*D*D*af*af*H)/(8*k)).*sin(af*t);
plot(t,y)
hold on;
x = ((-1*CM*Rho*pi*D*D*af2*af2*H2)/(8*k2)).*sin(af*t);
plot (t,x)
hold on;
z = ((-1*CM*Rho*pi*D*D*af3*af3*H3)/(8*k3)).*sin(af*t);
plot(t,z)
hold on;

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by