2017년 5월 10일 수요일

How to save dynamic data with each count and take the average of data?





I want to create an app in which the dynamic light intensity data taken from light sensor extension of PuraVida apps (https://puravidaapps.com/light.php) to be saved in a database or list for 30 seconds or 30 counts and then find out the average of the 30 light intensity data from the database/list. I can do it by saving the each data of the light sensor in a label text and find the average. but the problem is that it is a manual and lengthy method and the size of the app becomes large. Please give me a solution for these problem. The aia file and the block image is attached.


--

and then find out the average of the 30 light intensity data from the database/list.
see my answer here about how to get an average value https://groups.google.com/d/msg/mitappinventortest/GNi52HOZ50U/q2r5gkZuEAAJ
-- 
Sir, I have tried that , please find the aia file in the attachment. but I need an alternative simple method.  


-- 
what about using a sum variable to add all the temperatures and another counter variable to increment on each temperature received?
to get the average, just divide the sum variable by the counter variable...

-- 
Sir can you please help me with this blocks...I am not able to do it yet...

-- 
you might want to try something following my recommendations if if you get stuck, then post a screenshot of your relevant blocks

A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook   http://www.appinventor.org/book2 ... the links are at the bottom of the Web page.  The book 'teaches' users how to program with AI2 blocks.
There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro  and the aia files for the projects in the book are here:  http://www.appinventor.org/bookFiles  
How to do a lot of basic things with App Inventor are described here:  http://www.appinventor.org/content/howDoYou/eventHandling  .

Also do the tutorials http://appinventor.mit.edu/explore/ai2/tutorials.html to learn the basics of App Inventor, then try something and follow the
 Top 5 Tips: How to learn App Inventor

You will not find a tutorial, which does exactly what you are looking for. But doing the tutorials (not only reading a little bit) help you to understand, how things are working. This is important and this is the first step to do.

-- 
Sir here is the problem, I can do it manually by saving each intensity data over a time in a label and then calling them to plot a graph. But this limits its applicability for a large sent of data. Again, the timer count has been used in x axis as manually as you can see from the block image. Please refer me any method so that, a variable of database can store the intensity values after each count and after that I can extract them to plot a graph.


-- 
Avoid redundancy
Probably it helps to read chapter 19 - 21 in Dave's book http://www.appinventor.org/book2 to get an idea how to do DRY programming with App Inventor - Don't repeat yourself 

-- 
If you find yourself needing more blocks for more data, you are doing it wrong, and need to learn how to use lists.

See the Lists, Graphs, and Books and Tutorials sections of this FAQ:

-- 
I now prepared am example for you...

LigthIntensity.aia

-- 
Thank you very much sir.

-- 

댓글 없음:

댓글 쓰기