필터 지우기
필터 지우기

How perform Kinetic energy summation having matrix and vector

조회 수: 2 (최근 30일)
Giovanni Curiazio
Giovanni Curiazio 2022년 11월 6일
답변: Morgan 2022년 11월 6일
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