dpb
Posts:
6,841
Registered:
6/7/07
|
|
Re: text file data into matrix format
Posted:
Dec 17, 2012 10:09 AM
|
|
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...
--
|
|