help-octave
[Top][All Lists]
Advanced

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

Re: reading files


From: James Sherman Jr.
Subject: Re: reading files
Date: Wed, 29 Jul 2009 10:13:39 -0400

It seems that you are generating the filename correctly, but all that
is, is a string (or vector of characters).  What you want is the data
that is contained in the file with that name.  Depending on the format
of that file there are a number of ways to read it in.  The simplest
way is if the file is just a series of numbers, you could try

fid = fopen(filename, 'r');
data = fscanf(fid, '%d');
fclose(fid);

Hope this helps.

On Wed, Jul 29, 2009 at 3:05 AM, Nuncio M<address@hidden> wrote:
> Dear all,
>            I am trying to read some files and made this code
>
>         ext='.txt';
>         prefix='file_';
>         for i=1:2
>         l=i;
>         mid=int2str(l);
>         filename=([prefix,mid,ext]);
>         disp(filename);
>         endfor
>                 untill this point the code worked as expected. I loaded the
> 'filename'
> using the load command. Problem starts when i assign variable to
> different columns in file. For example: x=filename(:,1)
> this gives a value "f" for  x which is the first character of filename,
> file_1.txt.  I understand the problem this way.  Octave treats the
> filename as a matrix and assign the first column 'f' to variable x or
> may not be.  I am new to octave and I cannot figure out a way to
> overcome this. Any help in this regard would be greatly appreciated
>
> regards
> nuncio
>
> --
> Nuncio.M
> Research Scientist
> National Center for Antarctic and Ocean research
> Head land Sada
> Vasco da Gamma
> Goa-403804
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
>
>



reply via email to

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