matlab: cut out certain rows from data into new matrix -


i have few raw_data file similar below...each.dat file has different number of rows...however, in each raw_data file, first 2 rows , last 2 rows moved angle_data.dat file...so after programming through matlab code, each raw_data file create 2 new files: 1 angle_data file , final_data file...(final_data file remaining data raw_data file)...

raw_data1.dat

a b 0.0 1.2222 3.1111

c u 0.0 2.333 12.999

g t 3.4 2.3 5.666

r p 2.5 44.3 6.777

r q 8.222 5.999 0.344

after programming through matlab code, result below:

angle_data1.dat

a b 0.0 1.2222 3.1111

c u 0.0 2.333 12.999

r p 2.5 44.3 6.777

r q 8.222 5.999 0.344

final_data1.dat

g t 3.4 2.3 5.666

something following should work:

angledata=rawdata(1:2;end-1:end); finaldata=rawdata(3:end-2); 

i might have swapped rows , columns there, that's idea. don't have copy of matlab on machine test it.

edit: in case:

angledata=rawdata(:,1:2;:,end-1:end); finaldata=rawdata(:,3:end-2); 

though.. if have shell available, it'd lot faster do: (thanks amro improved last line)

head -n 2 raw_data.dat > angle_data.dat tail -n 2 raw_data.dat >> angle_data.dat head -n -2 raw_data.dat | tail -n +3 > final_data.dat 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

c# - SharpSVN - How to get the previous revision? -

php cli reading files and how to fix it? -