Kindly, i want to write a code for read analog signal 10 times and put these reading in a matrix as
for (int i=0;i<10;i++) {
a[i]=readRead(A0);
}
then i compare the elements of matrix if they belong to another matrix contain 50 elements as
int b[50] = { 512,519,520,600,...........................,400};
i do not want to make a loop to compare 50 times cause it will take a long time...i want a code to check with minimum time
Sorry, but brute force is sometimes the only way to go.
However, I think you are going to have problems with this just because of the noise inherent in reading the analog input, I don't think a check for exact equality will work very well.
Are you trying to match a pattern, or single values?
A binary search will cut the time a lot, as well as hashing.
Tell us what you want to do, not how you think you should do it
i have 4 analog signal patterns i want to check if the reads belongs to which pattern...so that i will make a database for each pattern then check if the new signal belong to the pattern with acceptable error rate
Use a hash or binary search to see if the first element is in the pattern array. Then check each one in turn, as soon as it fails to find a match quit the search.
Remember, the arduino does not have much memory for a "database".
Use a hash or binary search to see if the first element is in the pattern array. Then check each one in turn, as soon as it fails to find a match quit the search.
good idea
Remember, the arduino does not have much memory for a "database".
i will take it in my account..thank you
-----------------------but i want to check all the readings at the same time please help
"same time" is subjective. It sounds like you want to do this process with respect to the Arduino. Unfortunately, the Arduino doesn't have a "compare array of values to withing a specific threshold" instruction.
Time scales are relative...
To the Arduino, the "same time" is on the order of microseconds.
To the human eye, the "same time" is on the order of 100's of milliseconds.
To a Physicists I work with, the "same time" is on the order of picoseconds (or smaller).
To a Geologist, the "same time" is on the order of hundreds of years (or larger)...
Unfortunately, the Arduino doesn't have a "compare array of values to withing a specific threshold" instruction
i think it need a statistical operation to do like this things
Time scales are relative...
To the Arduino, the "same time" is on the order of microseconds.
To the human eye, the "same time" is on the order of 100's of milliseconds.
in the figure below you will see that i have 2 arrays and 4 analog reads ...
i want to know the position of the analog signal in which part (1 or 2 or 3 or4) as below