I have to make a program that as input gets the vectors t and y, and an order n, and I then have to make n functions that i have to use to make a least square fit. But my problem lies in making the n functions - they have to have the form:
$f_1(t)=1$, $f_2(t)=sin(wt)$, $f_3(t)=cos(wt)$, $f_4(t)=sin(2wt)$, $f_5(t)=cos(2wt)$
and so on until $f_n$.I have been trying to do this with a lot of for loops but I can't really get it to work - I was wondering if some one had an easy way to do it - I am trying to get the functions into a cell array, so that I can save the functions as functions of t :)
Something like this should work for you: