Combine or Superpose 151 Sine Waves?
이전 댓글 표시
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!!
채택된 답변
추가 답변 (1개)
Clifford Shelton
2012년 5월 4일
0 개 추천
댓글 수: 8
Walter Roberson
2012년 5월 4일
Let
yhat = horzcat(data.yhat);
and then ask
std(yhat,2)
and
max(yhat,[],2) - min(yhat,[],2)
Clifford Shelton
2012년 5월 4일
Walter Roberson
2012년 5월 4일
Sorry I tend to forget that weight argument. Try
std(yhat,[],2)
Except now that I think of it, that isn't going to give you useful information. Ummm, skip that one for now.
This and the max-min are intended to probe the reasonableness of such a tight range of sums.
Reminder: Using the yhat field was a guess on my part as to which field (if any) holds the fitted sine wave.
Clifford Shelton
2012년 5월 4일
Walter Roberson
2012년 5월 4일
Did you try the difference I suggested earlier, max(yhat,[],2) - min(yhat,[],2)
Clifford Shelton
2012년 5월 4일
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
Clifford Shelton
2012년 5월 4일
카테고리
도움말 센터 및 File Exchange에서 Gaussian Mixture Distribution에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!