How to loading two parts of the same file to two different matrixes? (matlab) -


i've 1 file (file.csv) filled integers in following format:

1,2,3,4,5,6,7,8,9,100 2,5,1,3,4,6,7,8,10,200 

i know using code:

load('file.csv') x = file 

x nxm matrix,where..

  • n number of rows in text file (in example above: n=2)
  • m number of numbers (divided comma) in each row (in example above: m=10)

my goal similar.

i want two matrices:

the first matrix (y): same matrix "x" without last column (in example above same of loading in matrix following file:

   1,2,3,4,5,6,7,8,9    2,5,1,3,4,6,7,8,10 

so result matrix n*(m-1) matrix (n=2 , m=10) ==> 2 rows , 9 columns

   |1 2 3 4 5 6 7 8 9 |    |2 5 1 3 4 6 7 8 10| 

the second matrix: remaining column (or more simply: n*1 matrix , have a row each element of last column)

in example above matrix be:

|100| |200| 

what easiest way this? (i'm matlab beginner).

thank in advance hint!

simplest way manually split variable file after loading

y=file(:,1:end-1); x=file(:,end); 

if data file large , worried running out of memory can import file using csvread

 y=csvread('file.csv',0,0,[0 0 n-1 m-2] # reads first m-1 columns , n rows  x=csvread('file.csv',0,m-1) %# reads mth column 

but need know number of rows , columns before first.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -