You are on page 1of 15

TUGAS MATEMATIKA NUMERIK,

SPRING MASS DAMPER – ONE DEGREE OF


FREEDOM
WITH EULER MATHOD
 %Code to solve spring-mass-damper problem

 clear; clc;

 %Parameters
 m=10; % in kg
 k=3; % in N/m
 c=1.2; %in N/m

 %Inputs
 h=0.001; % in second
 t_final=100; % in second
 N=t_final/h;

 %Initial Condition
 t(1)=0;
 x(1)=0.3;
 v(1)=0;

 % Update loop
 for i=1:N
 t(i+1)=t(i)+h;
 x(i+1)=x(i)+h*(v(i));
 v(i+1)=v(i)+h*(-k/m*x(i))+h*(-c/m*v(i));

 end

 fig = figure()

 set(fig,'color','green');

 plot(t,x)
 xlabel('Time (s)')
 ylabel('Position (m)')
 title ('Spring-mass-Damper Graphic , Position VS Time')

 fig = figure()
 Diantara berbagai ide betul dan salah , ada sebuah tanah
lapang.
 Temui aku disana.

 Rumi

You might also like