[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: |
Tue, 27 May 2014 05:12:01 -0400 |
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:
@address@hidden(address@hidden,$#],inv(arrange(remote(matrixTable,@address@hidden),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 <address@hidden> wrote:
> Hi Steven
>
> On Mon, May 26, 2014 at 9:39 PM, Steven Adrian <address@hidden> 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.
>
> With the Calc function defmath? How does it look like?
>
>> 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.
>
> 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
>
>> 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.
>
> Interesting. How does the "function to read the matrix" look like?
>
> Michael
>