Questa deve essere necessariamente

float vals[MAX_VAL][2];

Poi non vedo altri problemi.