Go Down

Topic: need help to write a code please (Read 1 time) previous topic - next topic

dany151

Jun 19, 2013, 04:38 pm Last Edit: Jun 19, 2013, 04:40 pm by dany151 Reason: 1
Kindly, i want to write a code for read  analog signal 10 times and put these reading in a matrix as

Code: [Select]
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

AWOL

Tell us what you want to do, not how you think you should do it.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

KeithRB

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.

dany151

Quote
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

dany151

Quote
the noise inherent in reading the analog input

good point
Quote
I don't think a check for exact equality will work very well

it must have some error rate

KeithRB

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".

dany151

Quote
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

Quote
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

Arrch

Define "same time".

To the Arduino?

To the human eye?

To a Physicist?

dany151

Quote
Define "same time".

To the Arduino?

To the human eye?

To a Physicist?


??????????????????

AWOL

Is there something wrong with your question-mark key?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Arrch


Quote
Define "same time".

To the Arduino?

To the human eye?

To a Physicist?


??????????????????


"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.

Sembazuru


Quote
Define "same time".

To the Arduino?

To the human eye?

To a Physicist?


??????????????????


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)...
http://www.catb.org/jargon/html/I/I-didn-t-change-anything-.html

dany151

Quote
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

Quote
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.
Quote


for me i process human eye signal with arduino...

Arrch

Quote
i think it need a statistical operation to do like  this things


Like what things? Can you try that sentence again?

dany151

Quote
Like what things? Can you try that sentence again?


like find the Mean absolute error or Mean squared  error

Go Up