help-octave
[Top][All Lists]
Advanced

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

FINAL: I would like to do this, but is not supported


From: John W. Eaton
Subject: FINAL: I would like to do this, but is not supported
Date: Fri, 24 Oct 2003 08:10:28 -0500

On 24-Oct-2003, charo <address@hidden> wrote:

| Hi all,
| 
| thanks to all replying to my question.
| 
| At the end, I used Geraint's advice as his/her comments fitted best my
| needs/thoughts.
| 
| Therefore, my script no looks as follows:
| 
| Using eval as in (1) I can load a bunch of frames in a binary octave
| file, and using eval as in (2) I can create a bunch of matrices with
| data from the frames in a regular way.
| 
| I didn't want to do it manually because that way is really error-prone
| and time consuming.
| 
| I really appreciate how people try to help each other and I hope to
| contribute to this great software soon. Cooperative programming is
| amazingly the best way to work.
| 
| Rosario
| 
| 
| ..........................................................................
| #! /usr/local/bin/octave -q
| 
| #sript name extractSG:
| #      RBC 2003
| 
| #echo on all;
| 
| numFrames=100000;
| if nargin != 2
|     Usage= "extractSG fileFrames outputFile",
|     return;
| endif
| eval(sprintf("load %s;",argv{[1,1]})); <-------------- (1)

You do not need eval for this.  You can use

  load (argv{1})

instead.

| for i=1:numFrames
|    fr = eval(sprintf("seq%03i",i));
|    scFr = getSignedSpatialContrast(fr);
|    eval(sprintf("sg_seq%03i = scFr;",i)); <------------ (2)

Why not use a cell array instead of individual variables?  Then you
could avoid this eval and write

  sg_seq{i} = scFr;

instead.  If you do this, you might want to preallocate the sg_seq
cell array ahead of time so it is not constantly resized one larger
than the last time.

|    if mod(i,31)==0
|       eval(sprintf("save -b %s sg_seq*;",argv{[2,1]}));

You don't need eval for this.  You can write

  save ("-b", argv{2}, "sg_seq*");

instead.

|    endif
|    eval(sprintf("clear seq%03i",i));

You can write

  clear (sprintf ("seq%03i", i));

instead.

| endfor
| eval(sprintf("save -b %s sg_seq*;",argv{[2,1]}));

Same as above, you don't need this eval either.  However, if you use a
cell array for sg_seq, you will need to use the mat-binary format
instead of Octave's binary format, at least for now.

jwe



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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