How perform Kinetic energy summation having matrix and vector

2 次查看(过去 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]

回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by