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);

Respuestas (3)

wael elsisi
wael elsisi el 18 de Jul. de 2021
Editada: Image Analyst el 18 de Jul. de 2021

0 votos

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 comentario

Image Analyst
Image Analyst el 18 de Jul. de 2021
What do you mean by "wired data"? Did it, or did it not, divide your send_windSpeed values by 100?

Iniciar sesión para comentar.

wael elsisi
wael elsisi el 18 de Jul. de 2021

0 votos

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 comentario

John D'Errico
John D'Errico el 18 de Jul. de 2021
Please don't use an answer to make a comment.

Iniciar sesión para comentar.

Image Analyst
Image Analyst el 18 de Jul. de 2021
Editada: Image Analyst el 18 de Jul. de 2021

0 votos

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 comentarios

wael elsisi
wael elsisi el 18 de Jul. de 2021
Editada: wael elsisi el 18 de Jul. de 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 el 18 de Jul. de 2021
Editada: wael elsisi el 18 de Jul. de 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.
wael elsisi
wael elsisi el 18 de Jul. de 2021
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;
Image Analyst
Image Analyst el 18 de Jul. de 2021
Not sure I can do more unless your channel is public and you give me the channel number, readChannelID.
wael elsisi
wael elsisi el 18 de Jul. de 2021
  • Channel ID: 1448319
Thank you.
Image Analyst
Image Analyst el 18 de Jul. de 2021
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.
Christopher Stapels
Christopher Stapels el 19 de Jul. de 2021
@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 el 19 de Jul. de 2021
Editada: wael elsisi el 20 de Jul. de 2021
Thank you for yoursupport.
  • Channel ID: 1450213
  • https://thingspeak.com/channels/1450213
PLease I need help to divide my data by 100.
wael elsisi
wael elsisi el 22 de Jul. de 2021
Is there is way to divide data by 100 ?.
Is it allowed in thingspeak?
Image Analyst
Image Analyst el 22 de Jul. de 2021
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.
Christopher Stapels
Christopher Stapels el 22 de Jul. de 2021
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
wael elsisi
wael elsisi el 23 de Jul. de 2021
Thank you for your support.
unfortunately it didn't work.
I have test it on another project and nothing be chanaged.
Image Analyst
Image Analyst el 23 de Jul. de 2021
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.
wael elsisi
wael elsisi el 24 de Jul. de 2021
Thank you for your support.
unfortunately,nothing be changed.
Image Analyst
Image Analyst el 24 de Jul. de 2021
Editada: Image Analyst el 24 de Jul. de 2021
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));
wael elsisi
wael elsisi el 24 de Jul. de 2021
Thank you for your suport.
I have copied & pasted it as you said.
Image Analyst
Image Analyst el 24 de Jul. de 2021
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.
wael elsisi
wael elsisi el 25 de Jul. de 2021
Image Analyst
Image Analyst el 25 de Jul. de 2021
OK. Glad it's working now. The array is clearly being divided by 100.
wael elsisi
wael elsisi el 25 de Jul. de 2021
unfortunately, nothing be changed.
Image Analyst
Image Analyst el 25 de Jul. de 2021
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?
wael elsisi
wael elsisi el 25 de Jul. de 2021
Sorry for annyoing you.
My data still as it was.
Image Analyst
Image Analyst el 25 de Jul. de 2021
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.

Iniciar sesión para comentar.

Comunidades de usuarios

Más respuestas en  ThingSpeak Community

Categorías

Más información sobre Prepare and Analyze Data en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 18 de Jul. de 2021

Comentada:

el 25 de Jul. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by