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 17, 2012 2:07 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 <kaa90e$v58$1@speranza.aioe.org>...
> On 12/12/2012 9:37 AM, ali wrote:
> ...
>

> > After 450 lines the format of the lines become
> > x=-113, y= 454, z= 37
> >
> > Which shows the space between = sign and the number is filled up with
> > signs. I tried strfind but did not work
> >
> > Now I want your advice about the general solution of this text file

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


thanx for the reply

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= 81, y=-137, z= 511

x= 176, y=-127, z= 448

x= 265, y=-109, z= 311

x= 322, y= -96, z= 55

x= 331, y= -91, z= 152

x= 317, y= -68, z= 41

x= 311, y= -45, z= 17

x= 321, y= -46, z= 139

x= 320, y= -71, z= 352

x= 299, y= -81, z= 498

x= 275, y= -81, z= 487

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.

thank you again for your help




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.