The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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 ]

Posts: 9,850
Registered: 6/7/07
Re: text file data into matrix format
Posted: Dec 17, 2012 10:09 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 12/17/2012 1:07 AM, ali wrote:
> dpb <> wrote in message <kaa90e$v58$>...

>> 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'];

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...


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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.