MATLAB: I’m using the input command. I want to NOT allow an imaginary input such as i , j , a+bi. Any ideas

input commandMATLAB

any help appreciated 🙂

Best Answer

It is not possible to put restrictions on what will be accepted by input(). If the user enters
delete('*.*')
at an input prompt then the deletion will proceed. Nothing you can do about it as long as you use input() without the 's' argument.
So if you care about what the user might enter then do not use input(). Or use the 's' option and validate the form of the values before converting from character to numeric. Or use input() and check the input before using it.
Related Question