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!
