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 11, 2012 12:48 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Nasser M. Abbasi" wrote in message <k94jl2$osv$1@speranza.aioe.org>...
> On 11/28/2012 2:37 AM, ali wrote:
> > hi
> >
> > i am a beginner in Matlab. i am just stuck in part of my project. i have a
> >text file which has the following format data.
> >
> >
> > x= 71, y= 7, z= 228
> >
> > x= 70, y= 5, z= 228
> >
> > x= 71, y= 5, z= 227
> >
> > x= 71, y= 6, z= 230
> >
> > x= 71, y= 6, z= 228
> >
> > x= 71, y= 7, z= 228
> >
> >
> > i want make a graph for each axis. for that i have to make a column matrix for x, y and z.

>
> There is nothing really called 'column matrix`. It is called just a matrix.
>

> >
> > i don't from where to start.
> >
> > plz any kind of code help would be a great for me.

>
> If you can change the program or function that was used to generate
> the output above so that it writes the output in simpler way,
> like this
>
> 71 7 228
> 70 5 228
>
> etc...
>
> it will be easier to read again
>
> But in either case, you need to read the file into a matrix.
> For the format you show up, you can use textscan with the
> appropriate format specifier.
>
> If the data was in the simpler form I show up, you can just
> read it much easier using one command such as
> importdata()
>
> http://www.mathworks.com/help/matlab/import_export/import-numeric-data-and-header-text-from-a-text-file.html
>
> --Nasser


Thank you nasser

as per your instruction i have written in following way:

fid = fopen('new1.txt'); % the file name is new1.txt which contains 1971X1 cell
mydata = textscan(fid, '%s %f, %s %f, %s %f');
fclose(fid);

but my data shows only for 450X1. i just can't understand why. but the data for x, y, z is extracted and showed in matrix form. but the problem is they are not showing all the data.

can you help me?



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.