How to avoid Dec2Hex non-negative integer error

I'm currently trying to convert a range of cells imported from a .csv from decimal to hex. However, I keep getting the error:
First argument must contain non-negative integers.
This is despite there not being any negative integers at all in the dataset. This is my current code:
f = @(x) dec2hex(round(x));
dataHex = [data(:, 1), varfun(f, data(:, 2:width(data)))];
Any help would be greatly appreciated.

 채택된 답변

Walter Roberson
Walter Roberson 2017년 5월 24일
편집: Walter Roberson 2017년 5월 24일

0 개 추천

You would get that message with that code if some of your values are nan.
Missing data could show up as NaN.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

질문:

2017년 5월 24일

편집:

2017년 5월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by