Calculating displacement, power, energy and torque from velocity data in .csv format.

36 ビュー (過去 30 日間)
Siddhi Kadam 2020 年 9 月 30 日
コメント済み: Siddhi Kadam 2020 年 9 月 30 日
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?
clc
A=csvread(' data .csv'); %reads csv data (';' prevents this from printing into the screen)
t=A(:,1);
time_hr=A(:,1)*3600; % sec to hr
speed=A(:,2)*1.60934; %miles to km
%Finding average speed:
avg_speed=mean(A(:,2))/10^3
% dist vs. time graph:
displacement=avg_speed.*time;
%plotting accln
dt=0.01;
Accln=dV./dt;
figure(1)
subplot(3,1,1)
plot(t,displacement)
title('displacement')
subplot(3,1,2) % m*n grid, p position
plot(t,speed) %plot speed vs. time
title('speed')
subplot(3,1,3)
plot(A(:,1),Accln)
title('Acceleration')
%------------------------------------------------------%
%Power Calculation:
%Step 1: Force Calculation
mass=1257;
Fa=mass*Accln;
% subplot(4,1,4)
% plot(A(:,1),Fa)
% title('Force')
Power=Fa.*speed;
% Torque calculation:
Torque=Fa*0.1778*1.1;
%Energy calculation
%Energy=integral(Power,0,A(:,1));
Energy=cumtrapz(Power);
figure(2)
subplot(3,1,1)
plot(A(:,1),Power) % plot power
title('Power')
subplot(3,1,2)
plot(A(:,1),Torque)
title('Torque')
subplot(3,1,3)
plot(A(:,1),Energy/1000)
title('Energy')

サインインしてコメントする。

採用された回答

Stefanie Schwarz 2020 年 9 月 30 日
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.
1 件のコメント表示非表示 なし
Siddhi Kadam 2020 年 9 月 30 日
Okay thank you for your help.

サインインしてコメントする。

その他の回答 (1 件)

Stefanie Schwarz 2020 年 9 月 30 日
Hello Siddhi,
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.
Grettings Steffi
5 件のコメント表示非表示 4 件の古いコメント
Siddhi Kadam 2020 年 9 月 30 日
Okay but using cumtrapz command I'm getting a plot of energy that is not correct. The energy should be rising instead I'm getting the following graph. How to do this using cumtrapz? Also how can I define a function of power if at all to use integral command. サインインしてコメントする。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!