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
Patch function - graphics objects: The patch function is used to generate a patch graphics object, which is made from 2-dimensional polygons. The patch is defined by its verti

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

Example of image processing: The other illustration generates a 5 × 5 matrix of arbitrary integers in the range from 1 to the number of colors; the resultant image is as shown

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

Print from the structure: To print from the structure, a disp function will show either the whole structure or a field. >> disp(package) item_no: 123 cost: 19.99

Program to Counting in a while loop: The script initializes variable counter to 0. Then, in the while loop action, each and every time the user successfully enter a number, th

I dont know how to input different videos on matlab program

Use of built-in colormaps: MATLAB has built-in colormaps, it is also possible to generate others by using combinations of any colors. For illustration, the following generates

Vectors of Structures: In numerous applications, involving database applications, information generally would be stored in the vector of structures, instead of in individual s

Example of Plotting from a Function: For illustration, the function can be called as shown below:      >> y = [1:2:9].^3      y =     1  27  125  343  729