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

4 次查看（过去 30 天）
Yoosuf2023-3-1

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 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);
0 个评论显示 -1更早的评论隐藏 -1更早的评论

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;

类别

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by