Checking for decimals values in input

8 次查看(过去 30 天)
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 中查找有关 Simulink 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by