How can i solve this problem
Afficher commentaires plus anciens

I can't fill the answers Coefficients [c....] and %fill here for proper ... of C(k)
Réponses (1)
David Hill
le 28 Oct 2021
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 commentaires
민호 김
le 28 Oct 2021
David Hill
le 28 Oct 2021
Show me your code for it and ask a specific question.
민호 김
le 28 Oct 2021
Modifié(e) : Walter Roberson
le 28 Oct 2021
David Hill
le 28 Oct 2021
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)
민호 김
le 28 Oct 2021
David Hill
le 28 Oct 2021
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
민호 김
le 28 Oct 2021
David Hill
le 28 Oct 2021
What should the coefficients be? The coefficients are complex, do you know if you are suppose to report only the magnitude?
Walter Roberson
le 28 Oct 2021
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.
Catégories
En savoir plus sur Descriptive Statistics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
