How perform Kinetic energy summation having matrix and vector
13 次查看(过去 30 天)
显示 更早的评论
How i could calculate the following kinetic energy:
N=100
The importan thing is that:
m is a vector [N,1]
V0 is a vector [1,3]
DeltaV_c is a matrix [N,3]
0 个评论
回答(1 个)
Morgan
2022-11-6
So kinetic energy must always be a scalar quantity, i.e. m is a scalar, velocity is a vector but by squaring it you're finding magnitude squared which is a scalar. Making some assumptions about your question I've made a function that should help you
function KE = kineticEnergy(m,V0,DeltaV_c)
% KINETICENERGY A function that takes mass (m) data
% and velocity data (V0 & DeltaV_c) to
% calculate total kinetic energy.
%
% Example usage: KE = KINETICENERGY(m,V0,DeltaV_c);
%
% INPUT ARGUMENTS
% ================
% m Mass data (size: [N,1])
% V0 Initial? velocity data (size: [1,3])
% DeltaV_c Changed? velocity data (size: [N,3])
%
% OUTPUT ARGUMENTS
% ================
% KE Total kinetic energy
KE = 0.5*sum(m.*norm(V0+DeltaV_c).^2);
end
I've also created a demo file to test that the function works with random data points:
% demo_kineticEnergy.m
% Initialize MATLAB
clear variables
close all
clc
% Create Random Data Arrays
N = 100;
m = rand(N,1);
V0 = rand(1,3);
DeltaV_c = rand(N,3);
% Call kineticEnergy.m
KE = kineticEnergy(m,V0,DeltaV_c);
Hopefully this helps, let me know if some assumptions I've made about your problem are incorrect.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Particle & Nuclear Physics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!