Normalized Sinc using matrix inputs

조회 수: 6 (최근 30일)
Eric Brown
Eric Brown 2022년 4월 5일
댓글: Eric Brown 2022년 4월 5일
My code is to use the formula sinc(x) = sin(x*pi)/(x*pi) to return a matrix of the same size as the input, and when dealing with a element equal to zero, it is to return a value of one.
function y = normsinc(vec)
y = sin(vec)*pi ./ (vec*pi);
This is what I have right now, but it can't use if statement to check the values of the input. I get the same size output as the input but for zeros I get NaN.
  댓글 수: 2
Jan
Jan 2022년 4월 5일
" but it can't use if statement to check the values of the input." - why not?
Eric Brown
Eric Brown 2022년 4월 5일
Its school work and they have 'tests' to check that the code follows their guidelines.

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2022년 4월 5일
What about appending:
y(isnan(y)) = 1;

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by