Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
to open and read a file

Subject: to open and read a file

From: Shobana

Date: 31 Dec, 2012 13:34:25

Message: 1 of 6

hai....

"fid = fopen('C:\Users\Public\Downloads\message.txt');
 %S = fscanf(fid,'%s);
fclose(fid);"

       In the above specified code i am getting error in the fopen statement please reply me if anybody knows .Thanks in advance

Subject: to open and read a file

From: steve nospam

Date: 31 Dec, 2012 16:53:59

Message: 2 of 6

On Dec 31, 7:34am, "Shobana " <manoharanshob...@ymail.com> wrote:
> hai....
>
> "fid = fopen('C:\Users\Public\Downloads\message.txt');
> %S = fscanf(fid,'%s);
> fclose(fid);"
>
> In the above specified code i am getting error in the fopen statement please reply me if anybody knows .Thanks in advance

i confirm i get the same error as well

fid = fopen('C:\Users\Public\Downloads\message.txt')

fid =

    -1

what version of matlab are you using?

Subject: to open and read a file

From: dpb

Date: 31 Dec, 2012 16:58:27

Message: 3 of 6

On 12/31/2012 7:34 AM, Shobana wrote:
> hai....
>
> "fid = fopen('C:\Users\Public\Downloads\message.txt');
> %S = fscanf(fid,'%s);
> fclose(fid);"
>
> In the above specified code i am getting error in the fopen statement
> please reply me if anybody knows .Thanks in advance

Use the optional return value to see what the cause of the failure is...

doc fopen

Most likely would be the file isn't where the fully-qualified name is on
the system on which you're running the code or this isn't an existing
subdirectory on the system...

--

Subject: to open and read a file

From: Shobana

Date: 1 Jan, 2013 12:18:08

Message: 4 of 6

dpb <none@non.net> wrote in message <kbsg7j$lav$1@speranza.aioe.org>...
> On 12/31/2012 7:34 AM, Shobana wrote:
> > hai....
> >
> > "fid = fopen('C:\Users\Public\Downloads\message.txt');
> > %S = fscanf(fid,'%s);
> > fclose(fid);"
> >
> > In the above specified code i am getting error in the fopen statement
> > please reply me if anybody knows .Thanks in advance
>
> Use the optional return value to see what the cause of the failure is...
>
> doc fopen
>
> Most likely would be the file isn't where the fully-qualified name is on
> the system on which you're running the code or this isn't an existing
> subdirectory on the system...
>
> --version is 7.11.0.584(R2010b)

Subject: to open and read a file

From: dpb

Date: 1 Jan, 2013 13:27:44

Message: 5 of 6

On 1/1/2013 6:18 AM, Shobana wrote:
> dpb <none@non.net> wrote in message <kbsg7j$lav$1@speranza.aioe.org>...
>> On 12/31/2012 7:34 AM, Shobana wrote:
>> > hai....
>> >
>> > "fid = fopen('C:\Users\Public\Downloads\message.txt');
>> > %S = fscanf(fid,'%s);
>> > fclose(fid);"
>> >
>> > In the above specified code i am getting error in the fopen statement
>> > please reply me if anybody knows .Thanks in advance
>>
>> Use the optional return value to see what the cause of the failure is...
>>
>> doc fopen
>>
>> Most likely would be the file isn't where the fully-qualified name is
>> on the system on which you're running the code or this isn't an
>> existing subdirectory on the system...
>>
>> --version is 7.11.0.584(R2010b)

Pretty much immaterial...

What was result of

[fid,msg] = fopen('C:\Users\Public\Downloads\message.txt')

???

Again,

doc fopen

--

Subject: to open and read a file

From: Shobana

Date: 2 Jan, 2013 04:00:12

Message: 6 of 6

dpb <none@non.net> wrote in message <kbuo8d$ek8$1@speranza.aioe.org>...
> On 1/1/2013 6:18 AM, Shobana wrote:
> > dpb <none@non.net> wrote in message <kbsg7j$lav$1@speranza.aioe.org>...
> >> On 12/31/2012 7:34 AM, Shobana wrote:
> >> > hai....
> >> >
> >> > "fid = fopen('C:\Users\Public\Downloads\message.txt');
> >> > %S = fscanf(fid,'%s);
> >> > fclose(fid);"
> >> >
> >> > In the above specified code i am getting error in the fopen statement
> >> > please reply me if anybody knows .Thanks in advance
> >>
> >> Use the optional return value to see what the cause of the failure is...
> >>
> >> doc fopen
> >>
> >> Most likely would be the file isn't where the fully-qualified name is
> >> on the system on which you're running the code or this isn't an
> >> existing subdirectory on the system...
> >>
> >> --version is 7.11.0.584(R2010b)
>
> Pretty much immaterial...
>
> What was result of
>
> [fid,msg] = fopen('C:\Users\Public\Downloads\message.txt')
>
> ???
>
> Again,
>
> doc fopen
>
> --
I got answer by changing the path of the file

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us