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
Finding sums and products: A very general application of a for loop is to compute sums and products. For illustration, rather than of just printing the integers 1 through 5, w

Logical scalar values: The MATLAB also has or and and operators which work element wise for the matrices: These operators will compare any of the two vectors or matric

Technique to create Nested structures: This technique is the most proficient. Though, the other technique is to build the nested structure one field at a time. As this is a ne

Built-in colormaps: The MATLAB has numerous built-in colormaps which are named; the reference page on colormap shows them. Calling the function colormap without passing any ar

Creating Cell arrays: There are many ways to create cell arrays. For illustration, we will create a cell array in which one element will store an integer, one element store ch

Function rmfield - structure: The function rmfield eliminates a field from the structure. It returns a new structure with field eliminated, but does not modify the original st

Replacing, Finding, and separating strings: There are numerous functions which find and replace the strings, or parts of strings, within the other strings and functions which

Matrix Multiplication: The Matrix multiplication does not mean multiplying term by term; and it is not an array operation. The Matrix multiplication has a very particular mean

Interchange rows : for illustration interchanging rows ri and rj is written as

IS Functions in Matlab: There are many functions which are built into MATLAB which test whether or not something is true; these function names start with the word is. As these