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!