Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
dec2hex error

Subject: dec2hex error

From: Leyo Joseph

Date: 8 Oct, 2012 15:28:06

Message: 1 of 2

Hello,
I have a variable clip1=6.51.
Making the following calculation and getting error==>
cl1=(10^(-clip1/10)*2^17)

cl1 =

  2.9276e+004

>> dec2hex(cl1)
??? Error using ==> dec2hex at 27
First argument must contain non-negative integers.

but

dec2hex(2.9276e+004)

ans =

725C

works well.

Not able to figure this out?

Subject: dec2hex error

From: Bruno Luong

Date: 8 Oct, 2012 16:03:16

Message: 2 of 2

>> x = 10^(-clip1/10)*2^17

x =

   2.9276e+04

>> fractionx = x - round(x)

fractionx =

   -0.1222

>> fractionx == 0

ans =

     0

>> dec2hex(round(x))

ans =

725C

% Bruno

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us