f



reading data in a text file column-by-column

OK let us suppose I have a text file (*.txt or *.dat) in which the data
is as follows:
1  100   1  1  2  1.        28.342
2  100   1  1      0.944   20.123
3  100   1  1  3  0.9       0.

Now I want to read from this text file and store the data in each
column in a separate matrix. For example, If I am able to store the
first column into a matrix "item_no", the matrix shall be like [1 2 3]
and the second column can be stored into a matrix "Quantity" and will
look like [100 100 100].

Can someone please help me out on this? I have a project and I cannot
proceed further without solving this problem.

P.S.: Note that there are 2 or more spaces between each column...how
will I read the second column and the next ones taking the spaces into
account?

Thanks...
MK

0
11/21/2005 7:08:31 PM
comp.soft-sys.matlab 211266 articles. 22 followers. lunamoonmoon (257) is leader. Post Follow

1 Replies
537 Views

Similar Articles

[PageSpeed] 48

MK wrote:
>
>
> OK let us suppose I have a text file (*.txt or *.dat) in which the
> data
> is as follows:
> 1 100 1 1 2 1. 28.342
> 2 100 1 1 0.944 20.123
> 3 100 1 1 3 0.9 0.
>
> Now I want to read from this text file and store the data in each
> column in a separate matrix. For example, If I am able to store the
> first column into a matrix "item_no", the matrix shall be like [1 2
> 3]
> and the second column can be stored into a matrix "Quantity" and
> will
> look like [100 100 100].
>
> Can someone please help me out on this? I have a project and I
> cannot
> proceed further without solving this problem.
>
> P.S.: Note that there are 2 or more spaces between each
> column...how
> will I read the second column and the next ones taking the spaces
> into
> account?
>
> Thanks...
> MK
>
>
MK,

Take a look at textread.

Scott
0
no18 (4537)
11/21/2005 7:28:47 PM
Reply: