Use of string variables, MATLAB in Mathematics

Use of string variables:

The Characters involve letters of the alphabet, punctuation marks, digits, white space, and control characters. The Control characters are characters which cannot be printed, but complete a task (like backspace or tab). The Whitespace characters involve the tab, space, newline (that moves the cursor down to the next line), and carriage return (that moves the cursor to the starting of the present line). The Leading blanks are blank spaces at the starting of a string, for illustration, 'hello', and trailing blanks are the blank spaces at end of a string.

There are some ways that the string variables can be formed. The one is using an assignment statement which is as shown below:

>> word = 'cat';

 

The other method is to read into the string variable. Recall that to read into the string variable by using the input function, the second argument 's' should be involved:

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

Enter a string: xyzabc

strvar =

xyzabc

 

If leading or trailing blanks are typed by the user, then these will be stored in the string. For illustration, in the following the user entered four blanks and then 'xyz':

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

Enter a string:     xyz

s =

xyz

Posted Date: 10/20/2012 4:29:11 AM | Location : United States







Related Discussions:- Use of string variables, Assignment Help, Ask Question on Use of string variables, Get Answer, Expert's Help, Use of string variables Discussions

Write discussion on Use of string variables
Your posts are moderated
Related Questions
Error-Checking for Integers: As MATLAB uses the type double by default for all the values, to check to make confirm that the user has entered an integer, the program have to c

fprintf function - File function: The fprintf function really returns the number of bytes which was written to the file, therefore if you do not want to see that number, suppr

Applications of Customized Strings: Labels, Prompts, Arguments to Functions: The one of very useful application of this is to involve numbers in strings that are used to plot

Illustration of Writing to files: Here is the other illustration in which a matrix is written to a file. At First, an arbitrary 2 × 4 matrix is generated, and then it is writt

Three-Dimensional Plots: The MATLAB has many functions which will display three-dimensional plots. Most of these functions have similar name as corresponding two-dimensional p

Indexed empty matrix: The Individual elements cannot be eliminated from matrices, as matrices always have the similar number of elements in every row. >> mat = [7 9 8; 4 6

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

sprintf function: The sprintf function works precisely like the fprintf function, but rather than printing it generates a string. Here are some illustrations in which the outp

Function isreal - complex numbers: The function isreal returns 1 for logical true when there is no imaginary part of the argument, or 0 for false when the argument does have a

Customizing Plots : There are numerous ways to customize figures in the Figure Window. On clicking the Plot Tools icon will bring up the Property Editor & Plot Browser, with ma