How can i solve this problem
이전 댓글 표시

I can't fill the answers Coefficients [c....] and %fill here for proper ... of C(k)
답변 (1개)
David Hill
2021년 10월 28일
Show me what you have tried for the C(k) equation above.
function C= FourierSeries(x,MaxK)
N=length(x);
n=0:N-1;
for k=1:2*MaxK+1
C(k)=%your equation look at sum() exp() .*
end
댓글 수: 9
민호 김
2021년 10월 28일
David Hill
2021년 10월 28일
Show me your code for it and ask a specific question.
민호 김
2021년 10월 28일
편집: Walter Roberson
2021년 10월 28일
David Hill
2021년 10월 28일
What have you done? I am not going to write the computation of C(k) for you, but I can help you once you have made an effort and ask a specific question.
% Fill here for proper computation of C(k)
민호 김
2021년 10월 28일
David Hill
2021년 10월 28일
N=length(x);
for k = 1 : 2*MaxK+1
C(k)=0;%must initially set to zero
for n = 0 : N-1
c= x(n+1) * exp((-1j*2*pi*k*n)/N);%you need x(n+1) and not n (look at your equation). pi is a constant not phi. 1j or 1i is amaginary whereas i or j are variables.
C(k)=C(k)+c;%need to change the variable name of what you are adding
end
C(k)=C(k)/N;%once the sum is completed you need to do the final division by N.
end
Alturnatively, you would not need the inner for-loop if you use sum() and do element-wise operations.
N=length(x);
n=0:N-1;
for k=1:2*MaxK+1
C(k)=sum(x.*exp(-1j*2*pi*k*n/N))/N;
end
민호 김
2021년 10월 28일
David Hill
2021년 10월 28일
What should the coefficients be? The coefficients are complex, do you know if you are suppose to report only the magnitude?
Walter Roberson
2021년 10월 28일
In MATLAB, [] is only used for building lists (and arrays) . [] is really the horzcat() or vertcat() function. The only place that [] is ever used for indexing in MATLAB is inside the Symbolic Engine, in the MuPAD programming language.
카테고리
도움말 센터 및 File Exchange에서 Descriptive Statistics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
