Trouble with import text file into Matlab

1 view (last 30 days)
Henry
Henry on 9 Aug 2016
Commented: Henry on 10 Aug 2016
Hi, Recently, I upgraded from matlab 2012b to matlab 2016a.
I neet to import some data stored in text files into matlab.
There are two columns in each file and are seperated by tab(\t in C).
I just use the Import Data menu.
When I imported the first file, matlab would auto name the first column VarName1 and the second column VarName2.
However, if I import the second file, matlab would name the both columns VarName3
In the old version of Matlab, when I did the same thing, matlab would auto name them VarName3 and VarName4.
I know I could change the name then import the data. But does anyone how what's wrong with that.
Thank you!

Answers (1)

Rob Jacobs
Rob Jacobs on 10 Aug 2016
This is happening because your first import created variables 'VarName1' and 'VarName2' in your workspace. When you open the next file, the Import Tool is avoiding giving the same variable names, because if you imported them a second time, they would overwrite the ones in the workspace. Hence you get 'VarName3' and 'VarName4' instead.
  1 Comment
Henry
Henry on 10 Aug 2016
In the Matlab 2012b I used before, I would get a VarName3 and VarName4 for those two columns.
However, In the new version, Matlab 2016a, it would name both columns "VarName3". That is a little annoying.

Sign in to comment.

Categories

Find more on Text Data Preparation in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!