Normalized Sinc using matrix inputs

7 vues (au cours des 30 derniers jours)
Eric Brown
Eric Brown le 5 Avr 2022
Commenté : Eric Brown le 5 Avr 2022
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 commentaires
Jan
Jan le 5 Avr 2022
" but it can't use if statement to check the values of the input." - why not?
Eric Brown
Eric Brown le 5 Avr 2022
Its school work and they have 'tests' to check that the code follows their guidelines.

Connectez-vous pour commenter.

Réponses (1)

Jan
Jan le 5 Avr 2022
What about appending:
y(isnan(y)) = 1;

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by