Calculating displacement, power, energy and torque from velocity data in .csv format.
14 views (last 30 days)
Show older comments
Commented: Siddhi Kadam on 30 Sep 2020
I have to find the displacement, power, energy and torque from a data that contains velocity of an object over time. The velocity and time data is in csv format. Could you please take a look and let me know if the results are correct? I'm a bit unsure about the energy one. How to use the 'integral ' command for this?
A=csvread(' data .csv'); %reads csv data (';' prevents this from printing into the screen)
time_hr=A(:,1)*3600; % sec to hr
speed=A(:,2)*1.60934; %miles to km
%Finding average speed:
% dist vs. time graph:
subplot(3,1,2) % m*n grid, p position
plot(t,speed) %plot speed vs. time
%Step 1: Force Calculation
% Torque calculation:
plot(A(:,1),Power) % plot power
The cumtrapz function uses the trapezoidal method. I don't know what this method does but I think it doesn't integrade the function you need. I'm sorry but I think I cannot help you futher because of my leak of knowledge in physics. I think it is the best if you look into a physics book and see how the power and energie is defined with an integral.
More Answers (1)
I found one mistake and one optional thing.
First the mistake. If you want to go from seconds to hours you don't multiply with 3600. You need to divided it with 3600.
Remember: 3600 seconds are 1 hour. So 1 seconds equals a 1/3600 hour.
The optional thing is: You don't need a dot before the operator if you have a calculate between a vektor and a skalar. The dot before the operator tells Matlab that you want him to calculate the element of position x in A with the element of the same position in B. But this is optional.
About the intgral function. I only read the help text of the integral function quickly but I think the second and third arguments are needed to be scalars. Second argument = starting point of the integral and thrid argument = end point of the integral. So it should be Energy=integral(Power,0,A(end,1)); <- end = last elemt of A(:,1) = last time point.
I hop I could help you a little.
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!