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
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

Recursive Functions: The Recursion occurs whenever something is defined in terms of itself. In the programming, a recursive function is a function which calls itself. The Recu

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

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,

Writing to Files: There are many lower level functions which can write to files. We will focus on the fprintf function that can be used to write a file and also to append to a

Plot types: Besides plot and bar, there are another plot types like stem plots, histograms, stem plots, area plots and pie charts, and also other functions which customize the

Changing Dimensions: In addition to transpose operator, the MATLAB has some built-in functions which change the dimensions or configuration of matrices, involving fliplr, resh

Blanks function: The blanks function will generate a string consisting of n blank characters-that are kind of hard to see here! Though, in a MATLAB if the mouse is moved to hi

Labels and Prompts: The script loads all the numbers from file into a row vector. It then splits the vector; it stores the initial element that is the experiment number in a v

Illustration of Spreadsheet Files: This reads the numbers in a double vector variable nums and the text in a cell array txt (the xlsread function forever returns the numbers f