Matlab - hexadecimal number conversion | MATLAB | Forum

Avatar

Please consider registering
Guest

Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

Register Lost password?
sp_Feed sp_TopicIcon
Matlab - hexadecimal number conversion
Avatar
avbuuren
New Member
Forum Posts: 1
sp_UserOfflineSmall Offline
1
January 4, 2018 - 9:22 am
sp_Permalink sp_Print

Hi, i would like to ask for help.

I am sending value to thingspeek periodically (lets say every 5 minute) where the original message is number. But the transmission changes the string(number value) into hex format, so instead of 40 i do receive 3430, after 5 minutes instead of value lets say 45 i receive 3435 and so on. I want to plot original values. I started with analysis tool writing code below, but i need help with function for changing hexadeciaml value back into original value.

readChannelID = xxxxx;
readAPIKey = 'xxxxxx;
writeChannelID = xxxxxx;
writeAPIKey = 'xxxxxx;

data = thingSpeakRead(readChannelID, 'ReadKey', readAPIKey,'OutputFormat','table');
analyzedData = data;

analyzedData.('Counter') = data.('Counter');
thingSpeakWrite(writeChannelID, analyzedData, 'WriteKey', writeAPIKey);

Tank you
Avatar
cstapels
Moderator
Forum Posts: 158
sp_UserOfflineSmall Offline
2
January 4, 2018 - 11:09 am
sp_Permalink sp_Print

try this:

value = '3435';

intConvert=str2num(char(sscanf(value,'%2x')'))

notice that value has to be a character vector.

If you can keep the device or program that is posting from converting to hex, ThingSpeak will definitely accept field values as string.  However, adding a string manipulation class your code may not be easy if you are using a limited hardware.  

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
36 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 252

Vinod: 164

cstapels: 96

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:

ibgedubo

aogomaeqaza

ureomug

itixuwidouzuv

eilimir

memozupi

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

 

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee