fid=-1

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

fid=-1

Federica
Hi,

I'm new to this forum and above all I'm new to Octave....in this forum I found some useful information on how Octave works but I'm having a lot of problems in trying to create a script with Octave 3.2.4 on Windows and so I decided to ask for your help. I'd like to solve a system of differential equations whose coefficients must be taken from a txt or csv file. Each row of the file gives the 8 coefficients needed by the the two equations. So I was thinking that dlmread could be useful but a first problem appears. The file cannot be opened and I don't understand why. I tried with

filename= "prova.txt"
fid=fopen(filename, "r")

but the fid=-1 so it cannot opened but why? the txt file contains numbers with 3 decimal numbers

Could you help me please? maybe the format of the numbers? I missed some package while downloading Octave?

Thank you really so mch,


Federica
Reply | Threaded
Open this post in threaded view
|

Re: fid=-1

James Sherman


On Thu, May 26, 2011 at 3:51 AM, Federica <[hidden email]> wrote:
Hi,

I'm new to this forum and above all I'm new to Octave....in this forum I
found some useful information on how Octave works but I'm having a lot of
problems in trying to create a script with Octave 3.2.4 on Windows and so I
decided to ask for your help. I'd like to solve a system of differential
equations whose coefficients must be taken from a txt or csv file. Each row
of the file gives the 8 coefficients needed by the the two equations. So I
was thinking that dlmread could be useful but a first problem appears. The
file cannot be opened and I don't understand why. I tried with

filename= "prova.txt"
fid=fopen(filename, "r")

but the fid=-1 so it cannot opened but why? the txt file contains numbers
with 3 decimal numbers

Hi Frederica,

My first guess (and I've done this many times) is that you're not in the correct directory.  Try comparing the output of "pwd" with the directory where your txt file is located.  If they are different, either use "cd" to change your current working directory or include the entire path in your filename.

Hope this helps,

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: fid=-1

andy buckle
On Thu, May 26, 2011 at 7:51 PM, James Sherman Jr. <[hidden email]> wrote:

>
>
> On Thu, May 26, 2011 at 3:51 AM, Federica <[hidden email]>
> wrote:
>>
>> Hi,
>>
>> I'm new to this forum and above all I'm new to Octave....in this forum I
>> found some useful information on how Octave works but I'm having a lot of
>> problems in trying to create a script with Octave 3.2.4 on Windows and so
>> I
>> decided to ask for your help. I'd like to solve a system of differential
>> equations whose coefficients must be taken from a txt or csv file. Each
>> row
>> of the file gives the 8 coefficients needed by the the two equations. So I
>> was thinking that dlmread could be useful but a first problem appears. The
>> file cannot be opened and I don't understand why. I tried with
>>
>> filename= "prova.txt"
>> fid=fopen(filename, "r")
>>
>> but the fid=-1 so it cannot opened but why? the txt file contains numbers
>> with 3 decimal numbers
>
> Hi Frederica,
> My first guess (and I've done this many times) is that you're not in the
> correct directory.  Try comparing the output of "pwd" with the directory
> where your txt file is located.  If they are different, either use "cd" to
> change your current working directory or include the entire path in your
> filename.
> Hope this helps,
> _______________________________________________
> Help-octave mailing list
> [hidden email]
> https://mailman.cae.wisc.edu/listinfo/help-octave

and if you do this it will tell you why it can't open it.

[fid msg]=fopen(filename, "r")



--
/* andy buckle */
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: fid=-1

Federica
Hi,

thank you so much for your help!!!

I'm feeling ashamed...I was not in the correct directory....I apologize for the stupid problems I find. I need to get some exercise!!!

Finally fid=3!!! :) so it's fine!!!

But if I try with

dlmread ("prova1.txt", "\t", 1,0)

and now it works!!!!


Thank you again!!! :)

I'm going to work on the script for solving the differential equations...I hope to succeed but.....if I don't I'll look for your help again!!! :)

Federica
Reply | Threaded
Open this post in threaded view
|

Re: fid=-1

Federica
.....I spoke too soon!!!

I wrote a script but it doesn't work.....would like to have a look at it? The error seems to be in the syntax....I'm attaching here the scripts!!!

Thank you again!!!


Federicafede.mrosso.m
Reply | Threaded
Open this post in threaded view
|

Re: fid=-1

marco atzeri-2
On Fri, May 27, 2011 at 10:05 AM, Federica wrote:
> .....I spoke too soon!!!
>
> I wrote a script but it doesn't work.....would like to have a look at it?
> The error seems to be in the syntax....I'm attaching here the scripts!!!

"doesn't work" is a bit vague, we need something more descriptive.

At first glance you need to specify the load format, and probably you
have wrong expectation on load format.

I suggest to play with save and load to check how octave create the
data and expect to receive them.

>
> Thank you again!!!
>
>
> Federica http://octave.1599824.n4.nabble.com/file/n3554639/fede.m fede.m
> http://octave.1599824.n4.nabble.com/file/n3554639/rosso.m rosso.m
>

Marco

PS:

 function name
       body
     endfunction
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: fid=-1

andy buckle
In reply to this post by Federica
On Fri, May 27, 2011 at 9:05 AM, Federica <[hidden email]> wrote:

> .....I spoke too soon!!!
>
> I wrote a script but it doesn't work.....would like to have a look at it?
> The error seems to be in the syntax....I'm attaching here the scripts!!!
>
> Thank you again!!!
>
>
> Federica http://octave.1599824.n4.nabble.com/file/n3554639/fede.m fede.m
> http://octave.1599824.n4.nabble.com/file/n3554639/rosso.m rosso.m

I also don't want to say too much without more info, but, It looks
like endfor is in the wrong place (and/or the indentation is odd).

--
/* andy buckle */
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: fid=-1

Federica
In reply to this post by Federica
.....I missed to explain the error I find.
 The error is:

parse error near line 57 of file C:\Cod_Oct\fede.m

          syntax error

>>> end

error called from:
error: C:\Octave\3.2.4_gcc-4.4.0\share\octave\3.2.4\m\micellaneous\run.m at line 46 column 2

Thanks!!! :)

Fede
Reply | Threaded
Open this post in threaded view
|

Re: fid=-1

Federica
In reply to this post by andy buckle
I tried with

load ("-ascii", "prova1.txt", "u", "b", "m0", "g", "a", "c", "area", "v0")

and it seems ok, it tells me that the fileis loaded

but save("-ascii", "prova3.txt", "u", "b", "m0", "g", "a", "c", "area", "v0")

but prova3.txt is empty!!!

maybe the file format could be wrong?

I'm attaching here also the file .txt....

thank you so much.....prova1.txt