Checking for decimals values in input

9 ビュー (過去 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 Center および File ExchangeSimulink についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by