help-octave
[Top][All Lists]
Advanced

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

Re: How to get Octave.app to work?


From: Vic Norton
Subject: Re: How to get Octave.app to work?
Date: Mon, 3 Sep 2007 15:39:27 -0400


On Sep 3, 2007, at 1:34 PM, Matthias Brennwald wrote:

Test 1. From terminal I execute
    vic$ /Applications/Octave.app/Contents/Resources/bin/octave
This gets me into octave-2.9.13. Now I execute
    octave-2.9.13> printf("%d\n", fopen ("~/desktop/
octave_output.txt", "wt"));
The output is
    3

You've just opened the file with write access...

That's what I want to do, write to it.

Test 2. From terminal I execute
    vic$ /usr/local/bin/octave
This gets me into octave-2.9.9. Now I execute
    octave> printf("%d\n", fopen ("~/desktop/octave_output.txt",
"wt"));
The output is
    -1

...and you're trying to open the same file with write access again. I
guess that might explain why this second call to fopen is not
successful. Not sure, though.

This is a different shell and a different version of octave, Matthias. The -1 output tells me that I can't write to the octave_output.txt file on my desktop because this octave (2.9.9) can't see it.

Why it can't see the file is what perplexes me. Every week I have octave-2.2.9 write files from within a perl script. The relevant perl line is
   `octave "$maindir/Octave/m/$octavescript"`;
The octave script does some computations and writes a comma-separated- value (.csv) file. The version of octave used resides in /usr/local/ bin/octave. This is the octave-2.9.9 of Test 2 above.

Inside the octave script ($octavescript) the code looks like this
file = [ "Output/spdrPortf39T_", deblank(base(baseIdx, :)), wgtSys, "_26"];
   file = [ file, ".csv" ];
   fid = fopen (file, "wt");
fprintf (fid, "Historical Sharpe-Optimal SPDR Portfolios (based on 39 weeks of 13-week returns)\n");
   ...
Since the script always works, the file id, fid, must be some positive integer. Why the file id is -1 in Test 2 is what perplexes me.


Regards,

Vic


reply via email to

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