csvread reading only column or full matrice in 2015a / b

1 view (last 30 days)
Hi !
I am currently triing to code something which would import ( or read in this case ) some csv files I have which look like this and which are 1024*1024.
I am working on two computers, one with Matlab 2015a, the other one with 2015b.
When I simply type in Matlab 2015a the code :
A = csvread ('file.txt')
I get an A matrice which is 1024*1024 ( as expected ). But when I type the same line, for the same file, in the same folder, on Matlab 2015b , I get an A matrice which is 1024*1.
And when I inserted in Matlab 2015a this line of code into a script, I then obtained the 1024*1 matrice ! I must say that I am now completely confused, as I never detailled in the code earlier something about importing only specifics rows/columns or whatever.
Do you have an idea about this issue ?
Thank you very much.

Accepted Answer

Walter Roberson
Walter Roberson on 6 Jan 2016
csvread() is for comma separated values; what you show is either space separated or tab separated.
If it is space separated then you can use
A = load('file.txt', '-ascii');
  1 Comment
Magea
Magea on 6 Jan 2016
Wonderful ! I see that you are right. i guess that I stayed on the csvread option because it kinda worked out perfectly well when it imported the 1024*1024 matrice.
So your suggestion solves my issue. But do you know why I had this weird behaviour ?
Thank you !

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!