help-octave
[Top][All Lists]
Advanced

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

Re: simple advice needed on input and output


From: Nicholas Jankowski
Subject: Re: simple advice needed on input and output
Date: Tue, 24 Jul 2012 09:15:50 -0400

On Tue, Jul 24, 2012 at 12:30 AM, vilsu <address@hidden> wrote:
> Hello C.-2
>
> I tried your way:
>
> I defined matrices to actave and then entered
>
> in
> save out.txt
>
> So far so good. Octave swallowed, calculated all the matrix operations,
> created out.txt, but somehow the contents of out.txt was only the matrices I
> had defined to octave.
>
> What went wrong?
>
> Could anyone has any suggestions, vilsu


did you read the help file for save  (help save)?

"Save the named variables V1, V2, ..., in the file FILE.  The special
filename `-' may be used to write output to the terminal. If no
variable names are listed, Octave saves all the variables in the
current scope."

Save will save variables to a file specified. if you don't tell it
what variables, it'll save them all. so, the matrices you defined to
octave were saved. how would octave save something you hadn't defined?
maybe I'm misunderstanding. can you give more detail on what it is
saving versus what you want it to save?

is it the results of the operations that aren't being saved? if those
aren't assigned to a variable, then Octave can't save it. Or, more
precisely, the answer will be stored in the default variable 'ans',
which can be saved, but the next line of your input file will also
save its output to 'ans', overwriting the first line.

If you can't define some variable to hold your answers so that you can
save them all to a file at the end, you'll need to somehow find a way
to evaluate one line of your input file at a time, and then save each
answer, or 'copy' the result from 'ans' to some other variable before
moving on to the next line.  I think in my first reply I pointed you
to some instructions to setting a loop, reading in the file one line
at a time and evaluating each command one at a time. I think someone
put in sample code, too, doing something just like that. it may be the
approach needed.

nickj


reply via email to

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