Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: text file data into matrix format
Replies: 10   Last Post: Dec 18, 2012 12:01 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
ali

Posts: 6
Registered: 11/28/12
Re: text file data into matrix format
Posted: Dec 18, 2012 12:01 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

dpb <none@non.net> wrote in message <kancij$ge5$1@speranza.aioe.org>...
> On 12/17/2012 1:07 AM, ali wrote:
> > dpb <none@non.net> wrote in message <kaa90e$v58$1@speranza.aioe.org>...
> ...
>

> >>
> >> use a format string that matches...
> >>
> >> fmt=['x=%f, y=%f, z=%f'];
> >> [x,y,z]=textread('yourfile.nam',fmt);
> >>

> ...
>

> > i have used the following codes
> >
> > b= importdata('new.txt');
> > c= b(2:2:end,:);
> > n=strrep(c,'=',' ')
> > c = textscan(n, '%s %f, %s %f, %s %f')
> >
> >
> > new.txt file contains the following amount of strings:
> >
> > x=-115, y=-143, z= 449
> > x= -70, y= -29, z= 511

> ...
> > x= 260, y= -83, z= 364
> > x= 248, y= -92, z= 230
> > but the textscan is not woriking. all i want to do is separating each x,
> > y , z values in each columns so that i could make a graph.
> >
> > plz would you help.

> ...
>
> Already did...sometimes the older tools are simpler/easier than the
> newer-fangled ones...use textread() instead--
>
> fmt=['x=%f, y=%f, z=%f'];
> [x,y,z]=textread('new.txt',fmt);
>
> If you only want the even-numbered rows, _now_ do the decimation--
>
> x(1:2:end,:)=[]; % etc., for others
>
> Or, of course, you can concatenate into a single array by
>
> data=[x y z];
>
> and then use data(1,:), etc., for x...
>
> --

thanx, it works.

many many thanx



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.