16 views (last 30 days)

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

Walter Roberson
on 13 Nov 2019

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)

James Tursa
on 13 Nov 2019

"... 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

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.