Take X Y Z coordinates and calculate kinetic energy

16 ビュー (過去 30 日間)
Daanish Qureshi
Daanish Qureshi 2023 年 1 月 11 日
編集済み: William Rose 2023 年 1 月 11 日
I have 3 dozen or so points that are all XYZ coordinates. I have a 3D matrix called sensor_data that is 428x3x36, as in there are 36 points where the x y z position was taken 428 times. I want to calculate the total energy of the system.
How would I do this? would I take each point, calculate the displacement, take the derivative to get velocity, then use KE = 1/2 * m * v^2 to get the kinetic energy of each point across the 428 times and then sum everything up? What if I am unsure of the mass?
Any suggestions?
Thank you all!

回答 (1 件)

William Rose
William Rose 2023 年 1 月 11 日
The solution you described sounds good. It is implicit in your proposed solution that the particles do not intreact with each other and that there is no potential energy (i.e. no "m*g*h" terms, or anything like that). If the particles interact, or if potential energy plays a role, then you will have to account for that in your calculaitons.
Assume each mass is 1 if you don't know the masses.
0. Let posData be the 428x3x36 array of particle positions. You already have this.
1. Let speedSqd=36x427 array, whose elements are the speed squared, of each particle for each time period. You can figure out how to calculate this. Matlab's diff() command will be useful.
2. Let tKE=total kinetic energy=1x427 vector, whose elements are the total kinetic energy at each instant. If all the masses are unknown, and estimated to be unity, then tKE is just 1/2 the column-wise sums of speedSqd:
If the masses are known, and are not all equal, then you have a mass vector m, 1x36. Then tKE is half the matrix product of m with speedSqd:
Good luck!
  1 件のコメント
William Rose
William Rose 2023 年 1 月 11 日
編集済み: William Rose 2023 年 1 月 11 日
[edit: correct typos in text; no changes to the code]
Since you did not attach a file of position data, I will create simulated data:
posData=zeros(428,3,36); %allocate array for position data
posData(1,:,:)=rand(3,36); %initial positions of 36 particles
Let each particle do a random walk in 3 dimensions for 427 time steps:
for i=2:428, posData(i,:,:)=squeeze(posData(i-1,:,:))+rand(3,36); end
Now we have simulated data.
Let us analyze the simulated data. Start by computing the velocities in x, y, z for each particle at each time:
dt=1; %time interval for each sample
Compute speedSqd for each particle at each time:
speedSqd=[vx.^2+vy.^2+vz.^2]'; %36x427
Assume there is a mass matrix m, and compute the total kinetic energy at each time:
m=ones(1,36); %your mass values will differ
tKE=m*speedSqd/2; %1x427
Done with calculations. Plot total energy versus time:
t=(0.5:1:426.5)*dt; %time vector
plot(t,tKE,'-r'); xlabel('Time'); ylabel('Energy')
Average total kinetic energy is 18. This suggests that the average kinetic energy of each particle is 0.5 at each time. This is consistent with the random walk used to generate the simulated positions: the velocity along each dimension is uniform on [0,1)/dt, where dt=1. Therefore the mean squared velocity is 1/3 along each dimension. SInce there are 3 dimensions, the mean total squared speed is 1/3*3=1. Since m=1 for each particle, the mean KE for each particle is 1/2.



Find more on Resizing and Reshaping Matrices 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!

Translated by