Evaluating a string, MATLAB in Engineering

Evaluating a string:

The function eval is used to compute a string as a function. For illustration, below is the string 'plot(x)'is interpreted to be a call to plot the function, and it generates the plot as shown in figure.


90_Evaluating a string.png

>> x = [2 6 8 3];

>> eval('plot(x)')

This would be helpful if the user entered the name of the type of plot to use. In illustration, the string that user enters (in this situation 'bar') is concatenated with the string '(x)' to generate the string 'bar(x)'; this is then computed as a call to the bar function as shown in figure.

Also, the name of the plot type is used in the title.

155_Evaluating a string1.png

Posted Date: 10/20/2012 5:38:27 AM | Location : United States

Related Discussions:- Evaluating a string, Assignment Help, Ask Question on Evaluating a string, Get Answer, Expert's Help, Evaluating a string Discussions

Write discussion on Evaluating a string
Your posts are moderated
Related Questions
Image Processing: The Images are represented as grids, or matrices, of picture elements (known as pixels). In MATLAB an image usually is represented as a matrix in which each

Symbolic Variables and expressions: The MATLAB has a type known as sym for the symbolic variables and expressions; these work with strings. The illustration, to generate a sym

Example to change the line width from the default: For illustration, to change the line width from the default of 0.5 to 1.5: >> set(hl,'LineWidth',1.5) As long as the

Example of Exponential function modular program: In order to view the distinction in the approximate value for e as n increases, the user kept choosing Limit & entering larger

Function used in sound files: The MATLAB has numerous other functions which let you read and play sound or audio files. In the audio files, sampled data for each audio channel

Scaling:   change a row by multiplying it by a non-zero scalar sri →  ri For illustration, for the matrix:

Technique to creating this structure: An alternative technique of creating this structure, that is not as efficient, includes using the dot operator to refer to fields in the

Function iscellstr - string function: The function iscellstr will return the logical true when a cell array is a cell array of all the strings, or logical false if not. >>

Illustration of Graphics properties: A particular property can also be exhibited, for illustration, to view the line width:     >> get(hl,'LineWidth')     ans =