Well, I am still not sure what you want to do according to your problem statement. But generally for data-fitting, you shall
First, propose the model first (i.e. maybe in this case your sine or cosine function or whatever, for example y=AsinBx+C), use Matlab function nlinfit to find best parameter set (A,B,C);
Second, use Matlab function nlparci to find confidence interval for A,B&C respectively;
Finally, use chi2test to evaluate your model based on best-fit (A,B,C) from nlinfit. If not satisfied, propose a new model.