what is wrong in this? how to use isinteger?
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Monnappa MB
am 13 Jun. 2020
Bearbeitet: Monnappa MB
am 13 Jun. 2020
function valid= valid_date3(y,m,d)
if ~isscalar(y) || ~isscalar(m) || ~isscalar(d) || ~isinteger(y) || ~isinteger(m) || ~isinteger(d) || y<1 || m<1 || d<1
valid=false;
return
end
valid=valid_date3(1900,2,28)
valid =
logical
0
.
1 Kommentar
Akzeptierte Antwort
Matt J
am 13 Jun. 2020
Bearbeitet: Matt J
am 13 Jun. 2020
To test whether a variable is integer-valued, you would do
y==round(y)
isinteger is for something completely different. It simply tests whether y is stored in floating point form, or as an integer data type, e.g.,
>> isinteger(5)
ans =
logical
0
>> isinteger(uint8(5))
ans =
logical
1
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Type Identification finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!