This project investigates the vibration of a cylinder subjected to hydrodynamic forces, simulating its behavior using MATLAB. The assignment is divided into two parts. The first part focuses on an energy extraction device consisting of a cylinder, an elastically mounted generator, and a damper. The project explores the effects of varying parameters like the Keulegan-Carpenter number (KC) and the damping coefficient (c) on the cylinder's displacement, vibration velocity, and extracted power. A numerical solution is obtained using the fourth-order Runge-Kutta method. The second part extends the analysis to hydrodynamic forces on a square cylinder. The project includes detailed explanations of the equations of motion, the numerical methods used, and the MATLAB code employed for the simulations. Results and discussions cover the impact of KC and damping on the cylinder's motion and power extraction, concluding that the damping coefficient and KC number are key parameters influencing the behavior of structures in fluid flow, emphasizing the importance of damping systems to reduce oscillations and optimize power extraction. The analysis is crucial for designing structures in marine environments, such as offshore wind turbines and oil mining equipment.