MATLAB: Problem importing files– matlab version changes

dataimport

Hi all,
I just updated my license from a 2014a to 2017b and I've noticed that the uiimport command is acting differently. I will post sample data for what I typically work with.
Looking through my code, you will notice that all of my variables are defined by the first row elements in the sample data. The 2014a version would read and import first line as the variable and the columns as the variable data. Now, the import is importing the WHOLE file in to the worspace instead of individual variables like I've just described.
Is there a way to make the 2017b version act like the 2014a version? Or is there a command that can do something along the lines that can generically call out columns to assign them to a variable? for example:
examplefile(:,1) = a
examplefile(:,2) = b
etc.
More specifically, how would I be able to call out a generic file? The file I've posted is just a sample, and I will be running other data files too.

Best Answer

OK, the mystery is solv'ed; the root cause is uiimport with it's "new and improved" flavor in wanting to use table class and then even if select columns it wants to turn text in which there are many more rows than unique values into categorical variables instead of char/cellstr and the initial code was written with string comparison operators which fail (silently, unfortunately) on categorical variables.

The workaround in short term is to convert the categorical variable to cellstr and carry on--I'll add this here to point out there really are some advantages if you will allow Matlab to have its way--consider the Details array; as you were using it, you presently are doing string comparisons to locate certain pieces of information as

Q = repmat('_1/4',[WrdVec,1]);
AQ=strcmp(Details,Q);

As previously noted, you do not need the Q array to do the comparison, simply compare the array to a single string does the same job with much less memory, the length of Q in this case is over 16K. IOW,

Q = '_1/4';
AQ=strcmp(Details,Q);

is identical in result or you can even do without the temporary Q altho I can see good reason to not bury "magic strings" in the code itself so that's not a bad factoring.

OTOH, if you let Matlab go ahead and convert the input to categorical, you can then do the same thing as

Q = '_1/4';
AQ=(Details==Q);

and eliminate the comparison function itself in favor of the equality operator.

Categorical variables have many other helpful uses in categorizing functionality as well that could turn out very useful besides just logical addressing. One nice feature that could be very helpful in debugging or otherwise looking at your data is

>> summary(Deteils)
   Deteils                 1 
   _0.1G                1789 
   _0.2G                 667 
   _0.3G                 819 
   _0.4G                 847 
   _0.500                  1 
   _1/4                  812 
   _1/8                  889 
   _100                   50 
   _500                  563 
   _65                    50 
   _8000                5130 
   _Alarm                100 
   _GPS receive            1 
   _Half                 566 
   _WOT                  495 
   _3/8                  678 
   _5000                  47 
   _Complete(HSTT)         1 
   <undefined>          2954 
>>

that produces a summary of the categories; easy to find a miscoded entry that way, maybe, if nothing else? (I just imported the file, didn't run the script so hadn't renamed the array you'll notice.)

All in all, I'd suggest revisiting the subject and consider perhaps using some of the newer features instead of beating MATLAB totally into submission.