[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Insert calc vector directly into spreadsheet cells?

From: Steven Adrian
Subject: Re: [O] Insert calc vector directly into spreadsheet cells?
Date: Mon, 26 May 2014 15:39:14 -0400


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.


On May 21, 2014, at 3:29 AM, Michael Brand <address@hidden> wrote:

> Hi Steven
>> Steven Adrian <address@hidden> writes:
>>> #+TBLFM: @address@hidden(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: @address@hidden = 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: @address@hidden = $#
> Or is there an interesting Calc vector function that is not easy to
> mimic?
> Michael

reply via email to

[Prev in Thread] Current Thread [Next in Thread]