Asked by ilyas mohamed
on 13 Nov 2019 at 0:11

hi there

i would like to know if we differentitate position to get velocity and acclereation, do we get same results and graphs going back form accleration to velocity and position using integration?

when differentiating my position to get velocity and acclereation i did work out all three of them by hand, quite sure it is right

here are the codes i have used

this is the differentation of my position and the codes for the plot

clc

close all

t=linspace(0,5,100) % time in seconds and number of points

a=0.5 % amplitude

f=5 % frequency

y=a*sin((2*pi)/f*t) % our posititon

plot(t,y,'b-');

title('position')

y2=(a*2*pi/f)*cos(2*pi/f*t) % velocity differentiated form position

plot(t,y2,'r-');

title('velocity')

y3=(-a*2*pi/f)^2*sin(2*pi/f*t) % accleration differetiated from velocity

plot(t,y3,'g-');

title('accleration')

ylabel('amplitude')

xlabel('time(s)')

this is integration of my acclereation to plot my velocity and position graphs

clear all

close all

clc

a=0.5 %amplitude

f=5 % frequency

t=linspace(0,5,100);

acc=(-a*2*pi/f)^2*sin(2*pi/f*t); % accleration obtained from differentation

figure(1)

plot(t,acc,'g-')

xlabel('Time (sec)')

ylabel('Amplitude (m/sec^2)')

title('acceleration')

velocity=cumtrapz(t,acc); % intgrated velocity from accleration using trapizoidal

figure (2)

plot(t,velocity,'r-')

xlabel('Time (sec)')

ylabel('Amplitude (m/sec)')

title('velocity')

position=cumtrapz(t,velocity); %intgrated velocity from accleration using trapizoidal

figure(3)

plot(t,position,'b-')

xlabel('Time (sec)')

ylabel('amplitude(m)')

title('position')

when i plot my differentitated graphs going from position to accleration, then integrate accleration to position, i dont obtain the same graphs, this is an experiment for findig positon through intgration using simple sine wave.

i would really appreciate any help

thank you

Answer by Walter Roberson
on 13 Nov 2019 at 2:01

y3=(-a*2*pi/f)^2*sin(2*pi/f*t) % accleration differetiated from velocity

is incorrect. That results in a positive leading factor that includes but the true differentiation only has a and is negative,

y3 = -4*a.*pi^2./f.^2 .* sin(2*pi./f .* t)

Sign in to comment.

Answer by James Tursa
on 13 Nov 2019 at 2:01

"... when differentiating my position to get velocity and acclereation i did work out all three of them by hand, quite sure it is right ..."

Well, no, unfortunately it isn't. The "a" doesn't get powers as a result of the differentiation ... it simply stays as a factor out front. And the minus sign doesn't get powers either, it simply appears outside of that. So,

y3=-a*(2*pi/f)^2*sin(2*pi/f*t); % accleration differetiated from velocity

:

acc=-a*(2*pi/f)^2*sin(2*pi/f*t); % accleration obtained from differentation

Then remember that integration is ambiguous up to a constant. So in addition to your numerical integration with cumtrapz( ), you will need to supply initial velocity and position. E.g.,

velocity0 = a*(2*pi/f)*cos(2*pi/f*t(1)); % initial velocity

position0 = a*sin((2*pi)/f*t(1)); % initial position

:

velocity=cumtrapz(t,acc)+velocity0; % intgrated velocity from accleration using trapizoidal

:

position=cumtrapz(t,velocity)+position0; %intgrated velocity from accleration using trapizoidal

ilyas mohamed
on 13 Nov 2019 at 12:46

thank you guys so mcuh james tursa and walter roberson with combination of both your answers i managed to get the correct answer but i have one more question.

how can you add noise to this data then and filter it

thank you very much

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.