How to Create the following discrete signal (Y[n]) in MATLAB?
조회 수: 9 (최근 30일)
이전 댓글 표시
x[n]= {-1,0,1,2,3,4,4,4,4,4}
Y[n] = x(n+2) -x(n-3)
댓글 수: 0
답변 (1개)
Jon
2019년 9월 9일
편집: Jon
2019년 9월 9일
You could do something like this
x = [-1 0 1 2 3 4 4 4 4 4]
n = 1:length(x)
y = NaN(1,n(end)) % preallocate providing NaN (Not a Number)for possibly unassigned values
idx = 4:n(end)-2; % valid range of indices
y(idx) = x(n(idx)+2) - x(n(idx)-3)
Note you have to take into account that x(n-3) is not defined until n =4 and x(n+2) is not defined after n=8
You could also pad the beginning and end with zeros and then only use the portion that you are interested in
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!