Checking for decimals values in input

9 visualizaciones (últimos 30 días)
Patirick Legare
Patirick Legare el 21 de Feb. de 2019
Respondida: Patirick Legare el 1 de Mzo. de 2019
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)

Respuestas (3)

Stephen23
Stephen23 el 21 de Feb. de 2019
assert(fix(r)==r,'Input r must be a whole number')

Adam
Adam el 21 de Feb. de 2019
validateattributes( r, { 'numeric' }, { 'scalar', 'integer' } )

Patirick Legare
Patirick Legare el 1 de Mzo. de 2019
Thanks guys

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by