I'm trying to figure out why my function isn't working. The data array undergoes a fit line transformation, and the data is written to a file. The next function aims to reverse the process. However, for some reason the reverse transformation is going wrong. The program reads the data file successfully, it is the transformation that is going wrong. All the variables are constants except for "t" the for loop counter. the arrays are shorts and "to", "to1", "tau", and "amp" are integers. the pointers point to shorts. I know I am missing something, I have graphed the arrays before, during, and after with no success.
Code:
if (ffit) {
for(int t=0;t<np;++t) {
fitvalue[t]= (data[t]-(28000+(t>=to&&t<=to1)*amp*exp((t-to/tau))));
ft=&fitvalue[t];
fwrite (ft,2,1,ffit);
}
}
// Test fit recovery
if (frecovery) {
for (int t=0; t<np; ++t) {
rcv=&recovery[t];
recovery[t]= (recovery[t]+(28000+(t>=to&&t<=to1)*amp*exp((t-to/tau))));
fwrite(rcv,2,1,frecovery);
}
}