Matlab 2016b hex2dec issues

I recently switched from 2014b to 2016b. One of my scripts uses hex2dec. It works fine with 2014b, but not 2016b. I double checked it is related to the version change, but I don't understand where or how. This is the error I am getting: Does anyone have any ideas?
Error using hex2dec>hex2decImpl (line 58)
Input to hex2dec should have just 0-9, a-f, or A-F.
Error in hex2dec (line 23)
d = hex2decImpl(char(h));

9 Comments

@Andrew: what value does char(h) have? Please show us the output of this:
+char(h)
This is how it is displayed in my code. I did a compare of the hex2dec script from 2014b to 2016b and there are some differences that it does that "out of range" check it is faulting on. still stumped though.
chgFile = importdata(file.list{iFile});
chgFile.names = chgFile.textdata(8:3:113,1);
chgFile.datax = reshape(hex2dec(chgFile.textdata(10:3:115,2:6)),36,5);
The char(h) mentioned in the first comment is the actual script that mathworks provides for hex2dec. I provided what mine looks like. Not sure that will help any.
@Andrew: Let me try again: please tell us what this displays:
+whateverinputyouprovidehex2dec
Note the + at the start. You might as well show us this too:
class(whateverinputyouprovidehex2dec)
Andrew
Andrew on 13 Jun 2017
Edited: Andrew on 13 Jun 2017
I don't know what you are asking. + I just found the hex2dec in C:\Program Files\MATLAB\R2014b\toolbox\matlab\strfun and renamed it and used it with my 2016b. It works, mathworks changed something in the code for hex2dec that was incompatible with my script.
Please show us
class(chgFile.textdata(10:3:115,2:6))
double(chgFile.textdata(10:3:115,2:6))
%I think this is what you are asking for.%
K>> class(chgFile.textdata)
ans =
cell
_%The double returns the following error.%_
K>> double(chgFile.textdata)
Error using double
Conversion to double from cell is not possible.
Walter Roberson
Walter Roberson on 13 Jun 2017
Edited: Walter Roberson on 13 Jun 2017
Is it possible that you are using R2017a rather than R2016b ? There was a change to R2017a for importdata to default to returning text items as the new (as of R2016b) string() class, and that can lead to the kind of difficulty you are seeing. I seldom use importdata...
Here is my version:
>> ver
MATLAB Version: 9.1.0.441655 (R2016b)

Sign in to comment.

Answers (0)

Categories

Asked:

on 12 Jun 2017

Commented:

on 13 Jun 2017

Community Treasure Hunt

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

Start Hunting!