Combine or Superpose 151 Sine Waves?
1 回表示 (過去 30 日間)
古いコメントを表示
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?
Thanks!!
0 件のコメント
採用された回答
Walter Roberson
2012 年 5 月 3 日
Guessing about which field you are referring to:
sum(horzcat(data.yhat),2) ./ 151
その他の回答 (1 件)
Clifford Shelton
2012 年 5 月 4 日
8 件のコメント
Walter Roberson
2012 年 5 月 4 日
The std() and max/min calls are just for information to try to figure out the problem. You can remove the std() call.
Remove the existing line
yhat = sum(horzcat(data.yhat),2) ./151;
and use
yhat_array = horzcat(data.yhat);
yhat = mean(yhat_array,2);
and then for information purposes
max(yhat_array, [], 2) - min(yhat_array, [], 2)
with no semi-colon
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!