Illustration of input function, MATLAB Programming

Illustration of Input function:

For illustration,

>> rad = input('Enter the radius: ')

Enter the radius: 5

rad = 5

If character or string input is preferred, 's' should be added after the prompt:

>> letter = input('Enter a char: ','s')

Enter a char: g

letter =

g

Note that though this is a string variable, the quotes are not shown. Though, they are shown in the Workspace Window.

If the user enters only spaces or tabs before pressing an Enter key, they are ignored and the empty string is stored in the variable:

>> mychar = input('Enter a character: ', 's')

Enter a character:

mychar =

''

Note that in this case the quotes are shown, to elaborate that there is nothing inside of the string.

Though, if the blank spaces are entered before other characters, they are involved in the string. In this illustration, the user pressed the space bar four times before entering the 'go':

>> mystr = input('Enter a string: ', 's')

Enter a string:     go

mystr =

  go

>> length(mystr)

ans =

 

Posted Date: 10/18/2012 5:48:15 AM | Location : United States







Related Discussions:- Illustration of input function, Assignment Help, Ask Question on Illustration of input function, Get Answer, Expert's Help, Illustration of input function Discussions

Write discussion on Illustration of input function
Your posts are moderated
Related Questions
I want to know how to create a numerical solution code for analysing temperature/isotherms on a 2d square plate with a singular heat source and opposing edges being held at constan

Your functions will allow you to create the following graph, which contains a piecewise function where a line exists in the first interval, a parabola in the second interval, and t

Input in a for Loop: The script below repeats the process of prompting the user for a number, and echo printing the number (that means simply printing it back out). A for loop

Example of variable names: If nothing appears when, who or whose is entered, which means there aren't any variables! For illustration, in the starting of a MATLAB session, the

Matlab Programming Vector Algebra : Create a program package for calculation of distances and intersections of lines and planes. Plot the results in a graphical representation

Obtain the input - Algorithms: From where does the input come? The two possible choices would be from an external file on a disk, or from the user, who enters the number by ty

Illustration of a conditional loop - While loop: As an illustration of a conditional loop, we will write a function which will find the first factorial which is greater than t

can you please help me with matlab coding for CMP? I am new to matlab and hence need help

Problem 1.  Use Matlab to solve the following system of linear equations: 2x + y + 3z = 1 2x + 6y + 8z = 3 6x + 8y + 18z = 5 Capture Matlab code and the result in a text fi

The fuel consumption of a certain make of car may not be exactly that rated by the manufacturer. Suppose ten cars of the same model were tested for combined city and highway fuel c