help-octave
[Top][All Lists]
Advanced

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

Re: fopen function


From: Doug Stewart
Subject: Re: fopen function
Date: Fri, 20 Dec 2019 19:10:11 -0500



On Fri, Dec 20, 2019 at 6:56 PM taquito <address@hidden> wrote:
Hi! I'm trying to open a text file with fopen. The name of the file is '352'.
If I do this

fid=fopen('352', 'rt');
formato=('%s %s %s %s %s %s %s %s');
data = ""> fclose(fid);

fid>1 then everything is Ok. But if I define the variables a=1, b=351, and
c=a+b, then:

a=1;
b=351;
c=a+b;

fid=fopen('c', 'rt');
formato=('%s %s %s %s %s %s %s %s');
data = ""> fclose(fid);

then fid=-1 and the file hasn't opened. Do you know why happen this, and how
can I solve it? Thanks!


the first 352 is a string and the second 352 is a number.
Try using the mat2str function


a=1;
b=351;
c=a+b;
sc=mat2str(c)
fid=fopen(sc, 'rt');
formato=('%s %s %s %s %s %s %s %s');
data = ""> fclose(fid);


I did not try this but I think it should work

--
DASCertificate for 206392


reply via email to

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