The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Center of gravity of a matrix
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

couturier

France
291 Posts

Posted - 02/08/2011 :  03:32:01 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 8.5 SR1
Operating System: XP Pro SP3

Does anyone know a fast way to compute the center of gravity of a matrix with Labtalk ?

For now, I'm doing it the hard way: Sum(Xi.Zi)/Sum(Zi) and Sum(Yi.Zi)/Sum(Zi) but it is something I want to perform MANY times and looping through rows and cols is way too slow.

Thanks

Sam Fang

293 Posts

Posted - 02/09/2011 :  04:54:33 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can use X-Function mstats to calculate the sum of a matrix.

To calculate the CG of a matrix, you can create two additional matrices for Xi*Zi and Yi*Zi first using Set Matrix Values.


Sam
OriginLab Technical Services

Edited by - Sam Fang on 02/09/2011 04:56:51 AM
Go to Top of Page

couturier

France
291 Posts

Posted - 02/18/2011 :  5:32:43 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
You can use X-Function mstats

Using Xf is a no-go (way too slow, because of overhead).

Anyway, if anyone is interested, I've found that the sum function works with matrix, result being stored in sum.total
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000