Checking for decimals values in input

조회 수: 3 (최근 30일)
Patirick Legare
Patirick Legare 2019년 2월 21일
답변: Patirick Legare 2019년 3월 1일
I am trying to write a function that wil display an error message if the input is not a whole number IE: the user the value 1.5 for the value of r in the code below.
Thank you.
function [R]=Newreshape(M,r,c)

답변 (3개)

Stephen23
Stephen23 2019년 2월 21일
assert(fix(r)==r,'Input r must be a whole number')

Adam
Adam 2019년 2월 21일
validateattributes( r, { 'numeric' }, { 'scalar', 'integer' } )

Patirick Legare
Patirick Legare 2019년 3월 1일
Thanks guys

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by