From: Jordan on
I know there must be an easy way to do this, but I'm new to matlab and have not been able to figure it out and have tried searching for a solution without luck.

I need to convert a signed integer to a 16-bit sign-extended (2's complement) hex number for output to a file.

For example:

3 -> 0003
-3 -> FFFD

I've tried using dec2hex(), but it does not support negative number. I've also tried playing around with a fi object but could not quite figure out how to make that work as I needed it to.

Any suggestions?

Thanks!