Computing the Fourier transfer of a function
조회 수: 3 (최근 30일)
이전 댓글 표시
I am asked to write a code to compute FT of this signal
x(t) = -1/2 * |x| +1
But, the instructions restrict us with only 7 lines (And with that given format below of the For loop), and here is the intial part of what i wrote, but can't get the idea throughly yet
t=-2:0.01:2;
w=-20:0.001:20;
x=-1/2 * abs(t)+1;
for i=1:
X(i)=
end
plot(w,abs(X));
댓글 수: 5
Bjorn Gustavsson
2022년 5월 25일
In the second line of your script you define w as an array of angular frequencies. For each step through the loop you want to calculate the integral of your function with a complex exponential with one frequency, that is one element out of w, not all of them. Also you need to think about how many times you need to run through the loop - for that you should learn to not hard-code the loop like you've done by look at the number of steps you need to make from the number of elements in the relevant array - look at the help and documentation of numel.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!