Buoy move with ocean wave
Hello guys,
I am here to ask a simulation question. I am trying to model how to buoy makes up and down according to ocean waves. The problem is I couldn’t add the sine wave in the figure. Here is the code what i wrote;
clear all;clc
radiusofcrank = 1;
angular_velocity = 60; % angular velocity in radians per second
for t = linspace(0, 1, 1000)
x_crank = radiusofcrank * cos(angular_velocity * t); %motion of the crank radius
y_crank = radiusofcrank * sin(angular_velocity * t);
x_buoy = 0; %x axis of buoy
y_buoy = y_crank – 5; % makes buoy moves up and down
plot(x_crank, y_crank); %crank
hold on;
plot([0, x_crank], [0, y_crank], ‘black’); %crank radius
plot(x_buoy, y_buoy, ‘o’, ‘MarkerSize’, 50, ‘MarkerFaceColor’, ‘b’); %buoy
plot([x_crank, x_buoy], [y_crank, y_buoy], ‘-‘, ‘Color’, ‘b’); % Connecting rod
theta = linspace(0, 2*pi, 100); %plots circle (2pi = 360 degree)
circle_x = radiusofcrank * cos(theta);
circle_y = radiusofcrank * sin(theta);
plot(circle_x, circle_y);
hold off;
title(‘Buoy Motion’);
xlabel(‘X-coordinate’);
ylabel(‘Y-coordinate’);
axis equal;
grid on;
pause(0.01);
end
% Sine Wave
t = 0.1:100;
Wave_amplitude_sine = 3; % Amplitude of the sine wave
wave_frequency = 0.01; % Frequency of the sine wave (in Hz)
% Create the figure and plot initial sine wave
h = plot(t,sin(2 * pi * wave_frequency * t));
title(‘Ocean Wave’);
xlabel(‘Time (s)’);
ylabel(‘Amplitude’);
grid on;
for time = 0:1:1000
phase = 2 * pi * wave_frequency * time; % Update the phase based on time and speed
set(h, ‘YData’, sin(2 * pi * wave_frequency * t + phase));
pause(0.028);
end
I need your help. Thank you!Hello guys,
I am here to ask a simulation question. I am trying to model how to buoy makes up and down according to ocean waves. The problem is I couldn’t add the sine wave in the figure. Here is the code what i wrote;
clear all;clc
radiusofcrank = 1;
angular_velocity = 60; % angular velocity in radians per second
for t = linspace(0, 1, 1000)
x_crank = radiusofcrank * cos(angular_velocity * t); %motion of the crank radius
y_crank = radiusofcrank * sin(angular_velocity * t);
x_buoy = 0; %x axis of buoy
y_buoy = y_crank – 5; % makes buoy moves up and down
plot(x_crank, y_crank); %crank
hold on;
plot([0, x_crank], [0, y_crank], ‘black’); %crank radius
plot(x_buoy, y_buoy, ‘o’, ‘MarkerSize’, 50, ‘MarkerFaceColor’, ‘b’); %buoy
plot([x_crank, x_buoy], [y_crank, y_buoy], ‘-‘, ‘Color’, ‘b’); % Connecting rod
theta = linspace(0, 2*pi, 100); %plots circle (2pi = 360 degree)
circle_x = radiusofcrank * cos(theta);
circle_y = radiusofcrank * sin(theta);
plot(circle_x, circle_y);
hold off;
title(‘Buoy Motion’);
xlabel(‘X-coordinate’);
ylabel(‘Y-coordinate’);
axis equal;
grid on;
pause(0.01);
end
% Sine Wave
t = 0.1:100;
Wave_amplitude_sine = 3; % Amplitude of the sine wave
wave_frequency = 0.01; % Frequency of the sine wave (in Hz)
% Create the figure and plot initial sine wave
h = plot(t,sin(2 * pi * wave_frequency * t));
title(‘Ocean Wave’);
xlabel(‘Time (s)’);
ylabel(‘Amplitude’);
grid on;
for time = 0:1:1000
phase = 2 * pi * wave_frequency * time; % Update the phase based on time and speed
set(h, ‘YData’, sin(2 * pi * wave_frequency * t + phase));
pause(0.028);
end
I need your help. Thank you! Hello guys,
I am here to ask a simulation question. I am trying to model how to buoy makes up and down according to ocean waves. The problem is I couldn’t add the sine wave in the figure. Here is the code what i wrote;
clear all;clc
radiusofcrank = 1;
angular_velocity = 60; % angular velocity in radians per second
for t = linspace(0, 1, 1000)
x_crank = radiusofcrank * cos(angular_velocity * t); %motion of the crank radius
y_crank = radiusofcrank * sin(angular_velocity * t);
x_buoy = 0; %x axis of buoy
y_buoy = y_crank – 5; % makes buoy moves up and down
plot(x_crank, y_crank); %crank
hold on;
plot([0, x_crank], [0, y_crank], ‘black’); %crank radius
plot(x_buoy, y_buoy, ‘o’, ‘MarkerSize’, 50, ‘MarkerFaceColor’, ‘b’); %buoy
plot([x_crank, x_buoy], [y_crank, y_buoy], ‘-‘, ‘Color’, ‘b’); % Connecting rod
theta = linspace(0, 2*pi, 100); %plots circle (2pi = 360 degree)
circle_x = radiusofcrank * cos(theta);
circle_y = radiusofcrank * sin(theta);
plot(circle_x, circle_y);
hold off;
title(‘Buoy Motion’);
xlabel(‘X-coordinate’);
ylabel(‘Y-coordinate’);
axis equal;
grid on;
pause(0.01);
end
% Sine Wave
t = 0.1:100;
Wave_amplitude_sine = 3; % Amplitude of the sine wave
wave_frequency = 0.01; % Frequency of the sine wave (in Hz)
% Create the figure and plot initial sine wave
h = plot(t,sin(2 * pi * wave_frequency * t));
title(‘Ocean Wave’);
xlabel(‘Time (s)’);
ylabel(‘Amplitude’);
grid on;
for time = 0:1:1000
phase = 2 * pi * wave_frequency * time; % Update the phase based on time and speed
set(h, ‘YData’, sin(2 * pi * wave_frequency * t + phase));
pause(0.028);
end
I need your help. Thank you! model, sinewave, crank MATLAB Answers — New Questions