emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Steven Adrian <sadrian@acumeniacal.com>
To: Michael Brand <michael.ch.brand@gmail.com>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: Insert calc vector directly into spreadsheet cells?
Date: Mon, 26 May 2014 15:39:14 -0400	[thread overview]
Message-ID: <7D34B671-E545-4AAF-A704-07D45B9A4715@acumeniacal.com> (raw)
In-Reply-To: <CALn3zoj69jUSBmOeAsxcXZ3rFyscaYFkPTFKL2D2YLPe=X+D_g@mail.gmail.com>

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 <michael.ch.brand@gmail.com> wrote:

> Hi Steven
> 
>> Steven Adrian <sadrian@acumeniacal.com> writes:
>>> #+TBLFM: @1$1..@1$10=index(10)
>>> 
>>> 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?
> 
> The vector elements can be accessed with Calc subscr() and Org "field
> coordinates":
> http://orgmode.org/manual/References.html
> 
> | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
> #+TBLFM: @1$1..@1$10 = subscr(index(10), $#)
> 
> In a TBLFM I would not use Calc vector functions like index() but a
> calculation of $#, here simply f(x) = x:
> 
> | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
> #+TBLFM: @1$1..@1$10 = $#
> 
> Or is there an interesting Calc vector function that is not easy to
> mimic?
> 
> Michael
> 

  reply	other threads:[~2014-05-26 19:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-17 21:40 Insert calc vector directly into spreadsheet cells? Steven Adrian
2014-05-20 15:23 ` Bastien
2014-05-21  7:29   ` Michael Brand
2014-05-26 19:39     ` Steven Adrian [this message]
2014-05-26 20:43       ` Michael Brand
2014-05-27  9:12         ` Steven Adrian
2014-05-27 18:06           ` Michael Brand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7D34B671-E545-4AAF-A704-07D45B9A4715@acumeniacal.com \
    --to=sadrian@acumeniacal.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=michael.ch.brand@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).