MATLAB: How to do this with a while loop script

while loop

I allow the user to input their own vector. Then my script shows the vector as a decimal number but with the integers as zeros. I now want my if statement showing if the vector has one or more numbers that are not integers as an incorrect input. I know how to get the script to display "incorrect input" but how would I get the part showing if the vector has one or more numbers that are not integers?

Best Answer

Use isinteger() which returns 0/1 for each element of the vector.
Then use any() to detect if there are any integers.
any(isinteger(vec))
Note that this does not and should not be done in a loop.