From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steven Adrian Subject: Re: Insert calc vector directly into spreadsheet cells? Date: Tue, 27 May 2014 05:12:01 -0400 Message-ID: <94E4DBCE-2BEF-4766-A49F-D20DCE9ABB29@acumeniacal.com> References: <87vbt04gq3.fsf@bzg.ath.cx> <7D34B671-E545-4AAF-A704-07D45B9A4715@acumeniacal.com> Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpDQm-0005fX-I9 for emacs-orgmode@gnu.org; Tue, 27 May 2014 05:12:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WpDQg-0004wd-15 for emacs-orgmode@gnu.org; Tue, 27 May 2014 05:12:24 -0400 Received: from vms173011pub.verizon.net ([206.46.173.11]:38313) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpDQf-0004wR-So for emacs-orgmode@gnu.org; Tue, 27 May 2014 05:12:17 -0400 Received: from new-host.home ([unknown] [72.66.109.185]) by vms173011.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id <0N6800H0L6W14C90@vms173011.mailsrvcs.net> for emacs-orgmode@gnu.org; Tue, 27 May 2014 04:12:02 -0500 (CDT) In-reply-to: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Michael Brand Cc: Org Mode Michael, Here is the custom calc function that is similar to subscr. It will work = for both vectors and matrices: (defmath getElem (indices m) (let (i j) (if (vectorp indices) (progn (setq i (cadr indices)) (setq j (nth 2 indices)) (nth j (nth i m)) ) (progn (setq i indices) (nth i m) ) ) ) ) Here is the table function to get matrix data from a table, take the = inverse, and write the result to a new table: #+TBLFM: = @1$1..@3$3=3DgetElem([@#,$#],inv(arrange(remote(matrixTable,@1$2..@3$4),3)= ) Thanks for the tip about orgtbl-ascii-plot. I have been working on a set = of notes about using calc and org mode that I am migrating over to read = more like a tutorial, and I am now thinking about changing the histogram = example to use orgtbl-ascii-plot instead of just writing the bin values = in a table. Steven On May 26, 2014, at 4:43 PM, Michael Brand = wrote: > Hi Steven >=20 > On Mon, May 26, 2014 at 9:39 PM, Steven Adrian = wrote: >> This is great. I wish I had seen this earlier. I did not know about >> the subscr function, but I had basically gotten to the same point by >> writing an equivalent custom calc function. >=20 > With the Calc function defmath? How does it look like? >=20 >> 1. I wrote a custom calc function called tailsInARow that uses the >> calc random function to simulate a coin toss and return the number >> of tails in a row. I used this function to fill a 20x20 table of >> values. I then used the calc histogram function in a table formula >> to read the table values, histogram the number of tails in a row, >> then write the histogram to a new table. >=20 > Didn't know that Calc has a histogram function. The histogram values > would fit perfectly to the ASCII plot within an Org table: > http://orgmode.org/worg/org-contrib/orgtbl-ascii-plot.html >=20 >> 2. I calculated a rotation matrix as a succession of individual >> rotations about x, y, and z axes. I then wrote the resulting matrix >> to a table. I then wrote a table function to read the matrix, take >> the inverse, and write the result to a new table. >=20 > Interesting. How does the "function to read the matrix" look like? >=20 > Michael >=20