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
Strcat function - Concatenation : The strcat function, though, will eliminate the trailing blanks from strings before concatenating. Note that in these illustrations, the trail

Illustration of logical built-in functions: The function find returns the indices of a vector which meet certain criteria. For illustration, to find all the elements in a vect

Print an imaginary number: To print an imaginary number, the function disp will show both parts automatically: >> disp(z1)    4.0000 + 2.0000i The function fprint

Animation: In this part we will observe a couple of ways to animate a plot. These are visuals, therefore the outcomes can't really be shown here; it is essential to type these

Illustration of a recursive function: illustration is of a recursive function which does not return anything, but simply prints. The below function prtwords receives a sentenc

Functions to create special matrices: The MATLAB also has various functions which create special matrices. For illustration, the zeros function generates a matrix of all zeros

Referring to and Modifying the Matrix Elements: To refer to matrix elements, the row and then the column indices are given in parentheses (always the row index initially and t

Example of Logical built-in functions: For equivalent to all the function, we should make sure that the entire elements in the vector are logically true. The one way of doing

Illustration of Writing variables to a file: For illustration, in the below session in the Command Window, 3 variables are generated; these are then exhibited using who. Then,

Built in recursive function in MATLAB: We have seen that the built-in function in MATLAB to compute factorials, termed as the factorial and we know how to implement the iterat