> From: Ronan Reilly
>
> I'm trying to write a unix (Mac OS X) batch script to call viewmat
> repeatedly on about 150 files and save the resulting bmp files.
> However,
> viewmat can't be called within the J console. In fact, I don't really
> want
> to display the viewmat output directly, I'm just interested in the
> generating the bmp files. Is there any way of achieving this within
> jconsole? Failing that, is there any way of suppressing the display of
> the
> viewmat display within the GUI, while still being able to call savemat?
>
Hopefully I've got this right:
You want to read a bunch of files that contain numeric arrays, convert each of
them to a bmp representation & save the conversions to file again?
You want to use Jconsole so any scripts that require Window Driver bits won't
work.
AFAICS the bit of the viewmat script that does the numerical conversion
(doesn't have any wd bits) is getvm_jviewmat_
NB. =========================================================
NB. getvm
NB.
NB. form: hue getvm data [;title]
NB.
NB. hue may be empty, in which case a default is used
NB. hue may be a N by 3 matrix of colors or a vector
NB. of RGB integers.
NB.
NB. returns:
NB. original data
NB. scaled data matrix
NB. angle (if any)
NB. title
So you should be able to read a file, use getvm_jviewmat_ to convert them to
bmp matrix and then write that matrix to file
require 'files bmp viewmat'
(50 5...@$10) fwrites jpath '~/temp/myfile.dat' NB. Create dummy data file
convert2BMP=: 3 : 0
fname=. >y
mydat=. fread fname
mydat=. 0&"....@}: ;._2 mydat NB. convert CRLF file to numeric matrix
bmpdat=. 1{:: '' getvm_jviewmat_ mydat
bmpdat writebmp 'bmp',~ _3}.fname
)
I'd probably use the J 'dir' script to list the files required and then iterate
through them.
load 'dir'
files =. 1 dir jpath '~temp/*.dat'
convert2BMP"0 files
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm