Go Down

### Topic: need help to write a code please (Read 3286 times)previous topic - next topic

#### dany151

##### Jun 19, 2013, 04:38 pmLast 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

#1
##### Jun 19, 2013, 04:55 pm
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.
I speak for myself, not Arduino.

#### KeithRB

#2
##### Jun 19, 2013, 05:04 pm
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

#3
##### Jun 19, 2013, 05:08 pm
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

#4
##### Jun 19, 2013, 05:13 pm
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

#5
##### Jun 19, 2013, 05:43 pm
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

#6
##### Jun 19, 2013, 05:54 pm
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

#7
##### Jun 19, 2013, 06:10 pm
Define "same time".

To the Arduino?

To the human eye?

To a Physicist?

#### dany151

#8
##### Jun 19, 2013, 06:20 pm
Quote
Define "same time".

To the Arduino?

To the human eye?

To a Physicist?

#### AWOL

#9
##### Jun 19, 2013, 07:19 pm
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.
I speak for myself, not Arduino.

#### Arrch

#10
##### Jun 19, 2013, 07:42 pm

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

#11
##### Jun 19, 2013, 07:52 pm

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

#12
##### Jun 19, 2013, 11:17 pm
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

#13
##### Jun 20, 2013, 12:02 am
Quote
i think it need a statistical operation to do like  this things

Like what things? Can you try that sentence again?

#### dany151

#14
##### Jun 20, 2013, 09:58 am
Quote
Like what things? Can you try that sentence again?

like find the Mean absolute error or Mean squared  error

Go Up