Saturday, April 4, 2015

HP Prime: Center of Mass - Matrix Representation

HP Prime:  Center of Mass - Matrix Representation

The HP Prime program CENTERMTX calculates the center of mass of the matrix M, where M represents the body.  The entries of M represents an array of molecules, each with assigned weights.  It is possible that the center of mass is located outside of the body. 


Note:  If gravity affects the particles equally, then the center of mass & center of gravity are identical.  

Formulas:

Xc = ∑(x * m)/∑m
Yc = ∑(y * m)/∑m


HP Prime:  CENTERMTX

EXPORT CENTERMTX(m)
BEGIN
// Center of Mass: matrix
// Matrix of mass
LOCAL s,tm,rt,ct,r,c;
// in MAKEMAT I=row,J=col
s:=SIZE(m);
r:=s(1);
c:=s(2);
// Total Mass
tm:=TRN(m*MAKEMAT(1,c,1))*
MAKEMAT(1,r,1);
tm:=tm(1,1);
// Row Total
rt:=TRN(m*MAKEMAT(I,c,1))*
MAKEMAT(1,r,1);
rt:=rt(1,1);
// Column Total
ct:=TRN(TRN(m)*MAKEMAT(I,r,1))*
MAKEMAT(1,c,1);
ct:=ct(1,1);
// center
RETURN [[rt/tm,ct/tm]];
END;

Example:  Locate the center of mass of the following body.




The center of mass:  [[ 2.08333333333, 2 ]]


Eddie


This blog is property of Edward Shore.  2015.



2 comments:

  1. Hi Eddie,

    Thank you for your blog. I really appreciate your articles on the HP Prime, especially with the lack of info I have about this calculator.

    I have used it lately for my Fluid Dynamics course and I am having trouble solving systems with the Solve app. Specifically, systems involving the Colebrook equation. I can't post it here because it won't let me attach photos, so her is the link to its Wiki page:
    http://en.wikipedia.org/wiki/Darcy_friction_factor_formulae#Compact_forms

    The problem is that the calculator either crashes or can't solve. Am I doing something wrong? Is there another way of solving equation systems?

    Thank you in advance

    ReplyDelete
    Replies
    1. Castro,

      You can email me the screen shot at ews31415@gmail.com.

      Eddie

      Delete

HP Prime and TI-84 Plus: Basic Wheatstone Full Bridge Circuit

HP Prime and TI-84 Plus:  Basic Wheatstone Full Bridge Circuit The program WHEATSTONE (HP Prime) and WHTSTONE (TI-84 Plus CE) deals wi...