that looks ok in isolation. what do you mean by 'not working'?
things to check
are the values in signalOutput integers, and are they all within the the range of column1?
are the values in column1 integers, and are they all withing the range of column2?
how to check these thing:
one technique is use assertions.
- add '#define <assert.h>' to the top of your program
- add '#define ELEMENTS(a) (sizeof(a) / sizeof(a[0]))' to the top of your program. this macro returns the number of elements in an array.
change your code to this:
Code:
#include <assert.h>
#define ELEMENTS(a) (sizeof(a) / sizeof(a[0]))
...
for(loop=0; loop<readings; loop++)
{
temp1 = signalOutput[loop];
assert(temp1 < ELEMENTS(column1)); // this will throw an assertion if an element is out of range. if the element is withing range, it will do nothing
temp2 = column1[temp1];
assert(temp2 < ELEMENTS(column2)); // this will throw an assertion if an element is out of range. if the element is withing range, it will do nothing
temperatureArray[loop] = column2[temp2];
printf("\n %i = %f", signalOutput[loop], temperatureArray[loop]);
another alternative is to use a debugger and step through to make sure you don't index out of the array bounds. or just print temp1 and temp2 and inspect to make sure they are not out of bounds