User input in the while loop - program, MATLAB in Mathematics

User input in the while loop:

Here is an illustration of running this script:

>> readonenum

Enter a positive number: -5

Invalid! Enter a positive number: -2.2

Invalid! Enter a positive number: c

??? Error using ==> input

Undefined function or variable 'c'.

Invalid! Enter a positive number: 44

Thanks, you entered a 44.0

Note that the MATLAB itself catches the character input and prints an error message and repeats the prompt whenever the c was entered.

 

 

 

Posted Date: 10/19/2012 6:13:57 AM | Location : United States







Related Discussions:- User input in the while loop - program, Assignment Help, Ask Question on User input in the while loop - program, Get Answer, Expert's Help, User input in the while loop - program Discussions

Write discussion on User input in the while loop - program
Your posts are moderated
Related Questions
Writing and Reading Spreadsheet Files: The MATLAB functions xlswrite & xlsread will write to and read from the spreadsheet files which have the extension .xls. For illustratio

Complex numbers: A complex number is commonly written in the form z = a + bi here a is known as the real part of the number z, b be the imaginary part of z, and i is √-1

Use of logical vector: Determine how many elements in the vector vec were greater than 5, the sum function can be used on the resulting vector isg: >> sum(isg) ans =

Function xlsread - file function: The function xlsread will read from the spreadsheet file. For illustration, to read from file just generated: >> ssnums = xlsread('ranexc

Strcat function - Concatenation : The strcat function, though, will eliminate the trailing blanks from strings before concatenating. Note that in these illustrations, the trail

Function fopen - file function: The permission string in the call to the fopen function identifies that the file is opened for writing to it. Just as when reading from a file,

Empty Vectors: An empty vector or in another words, a vector which stores no values, can be generated using the empty square brackets: >> evec = [] evec = [] >> lengt

Find Minimum and Maximum for each row To find the maximum (or minimum) for each row, the dimension of 2 (that is how a MATLAB refers to rows) can be identified as the third arg

Symbolic Expression The solve function solves an equation and returns the solution(s) as symbolic expressions. The answer can be converted to numbers by using any numeric funct

Nested IF-ELSE statements: The if-else statement is used to select between the two statements. In order to select from more than two statements, the if-else statements can als