I need to find minimum and maximum in a large dataset. It is a .csv file with 14 vectors(14 analog sensors) containing around 4 minuts of logging at 1 Hz.
I have found the average lib, but i doesn't seem to work well for the example on the webpage. Arduino Playground - HomePage
I know it is possible to find the minimum and maximum manual with comparing old and new values. But i find i very time consuming and inefficient for such large datasets.
So could any maybe tell me why the average lib don't work?
Or maybe has a lib like the average?
I have been spending most of the afternoon with figuring out what to do. I seems all a bit overwhelming
BastianGaardahl:
I need to find minimum and maximum in a large dataset. It is a .csv file with 14 vectors(14 analog sensors) containing around 4 minuts of logging at 1 Hz.
So that's 240 seconds * 14 values = 3360 integer values and you want to find max/min from that?
So if logging happens at a slow data rate of only 1 Hz, why don't you remember min/max values during logging, then after finished write another file MINMAX.TXT to the SD card containing min/max values?
BastianGaardahl:
But i find i very time consuming and inefficient for such large datasets.
How many KB may that be, 3360 integer values? 33 kilo bytes or less?
If you chose a quick and clever file access and processing logic, it will probably take less than two seconds to find max and min values. Is that really "time consuming"?
Yes the data is logged by the arduino, and Then saved on a SD card. Is Am Award that the calculations are not time consuming, but i Can assure you that 14 different new/old values in my code makes it all very messy. I all ready had to take 2 x megas to put i all together. So yes i Am maybe lazy, but i was worth the efford if it was possible.
This way, you could look for the maximum and minimum during the acquisition of the data.
It would only require 3 integer arays of length 14, so 3144 = 168 Byte.
That shouldn't be a problem on a Mega...
BastianGaardahl:
I would like to find min and max for every channel
So that's an array of 14 max and 14 min values = 28 values = 56 Bytes
Don't you have enough RAM left so that you cannot keep the min/max values while logging, then after closing the log file write the min/max values to a file named MINMAX.TXT?
Or don't you have two seconds to read the file and find out the min/max values later?
Thank you for the code example. I will try going with that. Yes i have the time to wait 2 seconds. But what i didn't had the time for was to use a whole day figuring out how to implement in in may code. But that problem is solved now thanks to a lot of useful comments and code examples. So thank you very much to you guys.