what is the error with my code
조회 수: 1 (최근 30일)
이전 댓글 표시
N = 4;
x = [ 3 4 5 6 ];
for k = 0 : N-1
for n=0:N-1
sum = sum + x.*(exp(-1*1i*2*pi*k.*n/N));
end
end
stem(sum)
댓글 수: 0
답변 (2개)
Adam Danz
2021년 6월 3일
편집: Adam Danz
2021년 6월 8일
> what is the error with my code
The error is,
N = 4;
x = [ 3 4 5 6 ];
for k = 0 : N-1
for n=0:N-1
sum = sum + x.*(exp(-1*1i*2*pi*k.*n/N));
% ^^^ ERROR
end
end
stem(sum)
What is causing the error (the question you intended to ask)?
sum() is a very commonly used Matlab function.
You're using it as a variable name but Matlab doesn't know it's a variable name because you haven't declared it as a variable by assiging a value to it.
Solution
Don't use sum as a variable name.
댓글 수: 0
Mahaveer Singh
2021년 6월 3일
% give the initial value of sum.
% like sum=0 (initial vlue of sum)
N = 4;
x = [ 3 4 5 6 ];
sum=0;
for k = 0 : N-1
for n=0:N-1
sum = sum + x.*(exp(-1*1i*2*pi*k.*n/N));
end
end
stem(y)
댓글 수: 1
참고 항목
카테고리
Help Center 및 File Exchange에서 Signal Generation, Manipulation, and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!