Error: Unrecognized Variable Name

5 views (last 30 days)
Patrick Saegesser
Patrick Saegesser on 9 Jan 2012
I'm trying to use strings read from an .xls as dataset variable names.
If I use them as imported and run the following code it works, although I get the information that they were modified by matlab to make them valid.
Dataset = set(Dataset,'VarNames',Names)
However, I need to manipulate them a bit. I.e. I need them to be in lower-case and without spaces. I therefore tried
Names = lower(Names);
Names = regexprep(Names, '[. ]','');
But when I run the code above after these manipulations (or only applying lower case) I get the following error:
??? Error using ==> dataset.subsref at 257
Unrecognized variable name 'Date'.
where 'Date' is the first string in Name. When checking by using
whos Name
in either case all the informations are the same except when removing the spaces memory size becomes obviously a little smaller.
So my question is what I did wrong that assigning the modified names doesn't work when it works with the unmodified ones?
Your help is very much appreciated!
  1 Comment
the cyclist
the cyclist on 9 Jan 2012
It would be easier to help you debug this if you supplied the briefest possible example of "Names" that gives the error, so that we could run your code and get the error more simply. Otherwise, we have a fair amount of guesswork to do.

Sign in to comment.

Answers (0)

Categories

Find more on Data Import from MATLAB 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!