dividing value by 100

I want to divide my data by 100
How to do it in MATLAB Analysis ?
data = thingSpeakRead(readChannelID, 'ReadKey', readAPIKey);
data = thingSpeakRead(readChannelID, 'ReadKey', readAPIKey)/100;
should I use write part ?
thingSpeakWrite(writeChannelID, analyzedData, 'WriteKey', writeAPIKey);

Answers (3)

wael elsisi
wael elsisi on 18 Jul 2021
Edited: Image Analyst on 18 Jul 2021
Thank you for your support.
I have tried your way but I got wired data.
send_windSpeed = thingSpeakRead(readChannelID, 'ReadKey', readAPIKey);
send_windSpeed = send_windSpeed/100;

1 Comment

What do you mean by "wired data"? Did it, or did it not, divide your send_windSpeed values by 100?

Sign in to comment.

wael elsisi
wael elsisi on 18 Jul 2021

0 votes

instead of getting float data I've got Integer value.
I have multiplay the value by 100.
Then I have asigned the result to high and low byte.
Then send data to thingspeak.
now I want to get the data on thingspeak.
I use Sigfox.

1 Comment

Please don't use an answer to make a comment.

Sign in to comment.

Image Analyst
Image Analyst on 18 Jul 2021
Edited: Image Analyst on 18 Jul 2021
To divide by 100, how about
send_windSpeed = send_windSpeed / 100;
You said you're getting integers. So, in your code
send_windSpeed = thingSpeakRead(readChannelID, 'ReadKey', readAPIKey);
send_windSpeed = send_windSpeed/100;
is send_windSpeed integer or floating point after the first line of code where you call thingSpeakRead()? The second line should not change it from floating point to integer.
To multiply by 100, you simply use * instead of /, like this:
send_windSpeed = send_windSpeed * 100;
Please reply as a comment to this (my) answer, not as a brand new answer to your original question.

24 Comments

wael elsisi
wael elsisi on 18 Jul 2021
Edited: wael elsisi on 18 Jul 2021
Thank you for your support.
Still have issue. ex: 1.95 ,I have got 100.
int16_t value = ((uint16_t)RecvData[0] << 8) + ((uint16_t) RecvData[1]);
How to write this in analyzing data ?.
wael elsisi
wael elsisi on 18 Jul 2021
Edited: wael elsisi on 18 Jul 2021
After I multiply by 100 in my arduino .
I sent data =3100
if I multiply by 100 then I get 310000
if I divide by 100 than I get 31.
data = int16(3100)
data = int16 3100
data = data * 100
data = int16 32767
data = data / 100
data = int16 328
I can't replicate your values. Anyway, int16 cannot handle a value of 310000 so it will clip to 32767.
sendSoil_T= thingSpeakRead(readChannelID, 'ReadKey', readAPIKey);
sendSoil_T = (sendSoil_T)/100;
sendSoil_H= thingSpeakRead(readChannelID, 'ReadKey', readAPIKey);
Although I divided by 100 but I didn't get divided value.
sendSoil_H=(sendSoil_H)/100;
Not sure I can do more unless your channel is public and you give me the channel number, readChannelID.
  • Channel ID: 1448319
Thank you.
Please give me code that runs. This code that I tried does not:
readChannelID = 1448319
send_windSpeed = thingSpeakRead(readChannelID, 'ReadKey', readAPIKey)
send_windSpeed = send_windSpeed/100;
It doesn't know what readAPIKey is. Make it easy for us to help you.
@wael elsisi that call only works for you because you are logged in to ThingSpeak. You need to make the channel public (use the sharing tab on your channel view) or share the read API key.
wael elsisi
wael elsisi on 19 Jul 2021
Edited: wael elsisi on 20 Jul 2021
Thank you for yoursupport.
  • Channel ID: 1450213
  • https://thingspeak.com/channels/1450213
PLease I need help to divide my data by 100.
Is there is way to divide data by 100 ?.
Is it allowed in thingspeak?
You can just divide your arrays by 100 like I already showed you. You can have your thingSpeak program run MATLAB code and do whatever you want.
I'm not a thingSpeak expert and I don't have time to delve into it for you. I suggest you call tech support.
Now that you have provided a public cahnnel, the original code works. I've added a name value pair to include 3 points. Your data includes some NAN values, dividing NAN by 100 has no effect. For the entries with numbers, the operation worked exactly.
readChannelID = 1450213;
windSpeed = thingSpeakRead(readChannelID, 'numPoints',3);
smallWindSpeed = windSpeed/100;
windSpeed =
NaN NaN
2867 7079
2867 7076
smallWindSpeedSM =
NaN NaN
28.6700 70.7900
28.6700 70.7600
Thank you for your support.
unfortunately it didn't work.
I have test it on another project and nothing be chanaged.
Replace line 27 by these three lines
fprintf('Before, send_Soil_T(1) = %f.\n', send_Soil_T(1));
send_Soil_T = send_Soil_T / 100;
fprintf('After, send_Soil_T(1) = %f.\n', send_Soil_T(1));
If the value is pure zero, then find some index other than 1 that is not zero.
Now, copy and paste what you see in the command window back here to prove that it is not dividing by 100.
Thank you for your support.
unfortunately,nothing be changed.
Wael - did you see my last comment??? Evidently not because you did not copy and paste anything back here, like what got printed out to the command window.
fprintf('Before, send_Soil_T(1) = %f.\n', send_Soil_T(1));
send_Soil_T = send_Soil_T / 100;
fprintf('After, send_Soil_T(1) = %f.\n', send_Soil_T(1));
Thank you for your suport.
I have copied & pasted it as you said.
But you didn't show the results. Make sure the command window is showing. Then set a break point the first line after 35 that will let you. Then copy and paste the command window contents back here.
OK. Glad it's working now. The array is clearly being divided by 100.
unfortunately, nothing be changed.
So before it was 3173, and after it is 31.73 and you say nothing has changed? What is your justification for saying that 31.73 is the same as 3173? To everyone else it looks like it's been divided by 100, so why not you?
Sorry for annyoing you.
My data still as it was.
Did you replot the data after it was divided by 100? Just dividing the array won't do a replot automatically. That is a separate step you must do explicitly.

Sign in to comment.

Communities

More Answers in the  ThingSpeak Community

Categories

Tags

Asked:

on 18 Jul 2021

Commented:

on 25 Jul 2021

Community Treasure Hunt

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

Start Hunting!