Using the below code and I have been able to successfully created 151 different sine waves all fit to my data set.
y = Score(:); n = 501; t = (1:501)'; games = 1:501;
data(1:151) = struct('X',NaN(501,3),'bhat',NaN(3,1),'yhat',NaN);
for ii = 1:151 tmp = 2*pi*(sincos(ii))*t; data(ii).X = rand(501,3); data(ii).X(:,2) = cos(tmp)'; data(ii).X(:,3) = sin(tmp)'; data(ii).bhat = data(ii).X\y; data(ii).yhat = data(ii).bhat(1)+data(ii).bhat(2)*cos(tmp)+data(ii).bhat(3)*sin(tmp); end
My question is how do I combine or superpose all 151 sine waves into one sine wave?
No products are associated with this question.
Guessing about which field you are referring to:
sum(horzcat(data.yhat),2) ./ 151
Thanks a bunch. Both of the suggestions work. But now it seems that the single sin wave created is extremely thin. My data set has values that range between 0-20.
and each of the 151 sine waves constructed separately also have amplitudes that fit the range of values.
When the sin waves are all added together using your above suggestion..the single sine wave only has a value range between 5-5.4. This makes the newly constructed single sine wave look like a small tightrope when plotted with my data set and isn't very useful visually to see the best fit.
Do you have any idea how to remedy that problem?