Creating customized strings, MATLAB in Mathematics

Creating Customized strings:

There are many built-in functions which create customized strings, including blanks, char, and sprintf.

We know that the char function can be used to convert from an ASCII code to character, as the illustration shows:

>> char(97)

ans =

a

 

A char function can also be used to generate a matrix of characters. Whenever using the char function to generate a matrix, it will automatically pad the strings within the rows with blanks as essential so that they are all of similar length, just like the strvcat.

 

>> clear greetmat

>> greetmat = char('Hello','Goodbye')

greetmat =

Hello

Goodbye

>> size(greetmat)

ans =

2  7

Posted Date: 10/20/2012 5:06:43 AM | Location : United States







Related Discussions:- Creating customized strings, Assignment Help, Ask Question on Creating customized strings, Get Answer, Expert's Help, Creating customized strings Discussions

Write discussion on Creating customized strings
Your posts are moderated
Related Questions
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

Histogram: The histogram is a particular type of bar chart which shows the frequency of occurrence of the values within a vector. The Histograms use what are known as bins to

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

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

Fliplr function: The fliplr function "flips" the matrix from left to right (in another words the left-most column, the first column, become the last column and so on), and the

Differentiation: The derivative of a function y = f(x) can be written as follows or f  '(x) and is defined as the rate of change of the dependent variable y with respe

Pie chart - plot functions: The MATLAB also has a function pie which will generate a pie chart. Calling the function with the form pie (vec) draws a pie chart, by using the pe

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,

Example of Recursive functions: This definition is recursive as a factorial is defined in terms of the other factorial. There are two parts to any recursive definition: the co

Illustration of Labels and prompts: The program below prompts the user for endpoints (x1, y1) and (x2, y2) of a line segment, and computes the midpoint of the line segment, th