From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steven Adrian Subject: Re: Insert calc vector directly into spreadsheet cells? Date: Mon, 26 May 2014 15:39:14 -0400 Message-ID: <7D34B671-E545-4AAF-A704-07D45B9A4715@acumeniacal.com> References: <87vbt04gq3.fsf@bzg.ath.cx> 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]:51469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wp0kI-0000Th-Ga for emacs-orgmode@gnu.org; Mon, 26 May 2014 15:39:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wp0kC-0000LN-Vu for emacs-orgmode@gnu.org; Mon, 26 May 2014 15:39:42 -0400 Received: from vms173011pub.verizon.net ([206.46.173.11]:23752) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wp0kC-0000Kw-Qg for emacs-orgmode@gnu.org; Mon, 26 May 2014 15:39:36 -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 <0N67000KC59FQ1I0@vms173011.mailsrvcs.net> for emacs-orgmode@gnu.org; Mon, 26 May 2014 14:39:16 -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, 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. I understand that using a calc function in a table formula is = inefficient, since it is executed for every table cell. But for small = tables, I think the combination of table formulas and calc functions is = extremely powerful. Here are two examples of mine: 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. 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. I think calc is well suited for small problems like this for which I = want to have a record of what I did later. But I am always looking for = better approaches, if you have any to suggest. Steven On May 21, 2014, at 3:29 AM, Michael Brand = wrote: > Hi Steven >=20 >> Steven Adrian writes: >>> #+TBLFM: @1$1..@1$10=3Dindex(10) >>>=20 >>> But the formula above just puts the whole vector in each cell. Can = anyone >>> tell me how to put the vector values in individual cells? >=20 > The vector elements can be accessed with Calc subscr() and Org "field > coordinates": > http://orgmode.org/manual/References.html >=20 > | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | > #+TBLFM: @1$1..@1$10 =3D subscr(index(10), $#) >=20 > In a TBLFM I would not use Calc vector functions like index() but a > calculation of $#, here simply f(x) =3D x: >=20 > | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | > #+TBLFM: @1$1..@1$10 =3D $# >=20 > Or is there an interesting Calc vector function that is not easy to > mimic? >=20 > Michael >=20