dividing value by 100
Mostrar comentarios más antiguos
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);
1 comentario
Image Analyst
el 18 de Jul. de 2021
How about
data = data / 100;
Respuestas (3)
wael elsisi
el 18 de Jul. de 2021
Editada: Image Analyst
el 18 de Jul. de 2021
1 comentario
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?
wael elsisi
el 18 de Jul. de 2021
0 votos
1 comentario
John D'Errico
el 18 de Jul. de 2021
Please don't use an answer to make a comment.
Image Analyst
el 18 de Jul. de 2021
Editada: Image Analyst
el 18 de Jul. de 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 comentarios
wael elsisi
el 18 de Jul. de 2021
Editada: wael elsisi
el 18 de Jul. de 2021
wael elsisi
el 18 de Jul. de 2021
Editada: wael elsisi
el 18 de Jul. de 2021
data = int16(3100)
data = data * 100
data = data / 100
I can't replicate your values. Anyway, int16 cannot handle a value of 310000 so it will clip to 32767.
wael elsisi
el 18 de Jul. de 2021
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
el 18 de Jul. de 2021
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
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
el 19 de Jul. de 2021
Editada: wael elsisi
el 20 de Jul. de 2021
wael elsisi
el 22 de Jul. de 2021
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
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
el 23 de Jul. de 2021
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
el 24 de Jul. de 2021
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
el 24 de Jul. de 2021
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
el 25 de Jul. de 2021
Image Analyst
el 25 de Jul. de 2021
OK. Glad it's working now. The array is clearly being divided by 100.
wael elsisi
el 25 de Jul. de 2021
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
el 25 de Jul. de 2021
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.
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.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




