|
|
Re: text file data into matrix format
Posted:
Dec 11, 2012 1:41 AM
|
|
On 12/10/2012 11:48 PM, ali wrote:
> > 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. >
are you saying it is read only 450 lines from the file, while the file contains 1971 lines? humm... may be you can look at line 451 in the textfile and see if has anything weired in it.
I tried this on my matlab 2012a for 3 lines, and everything worked ok. I do not know why it stopped at line 450. If you post your textfile somewhere may be you'll get better help.
---foo.txt----------- x= 71, y= 7, z= 228 x= 70, y= 5, z= 228 x= 71, y= 5, z= 227 ----------------------
EDU>> fid = fopen('foo.txt'); EDU>> mydata = textscan(fid, '%s %f, %s %f, %s %f'); EDU>> mydata{:}
ans = 'x=' 'x=' 'x='
ans = 71 70 71
ans = 'y=' 'y=' 'y='
ans = 7 5 5
ans = 'z=' 'z=' 'z='
ans = 228 228 227
--Nasser
|
|