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 products by for loop: an illustration, when 5 is passed to be the value of the input argument n, the function will compute and return 1 + 2 + 3 + 4 + 5, or 15: >> s

True color matrice: The true color matrices are the other way to represent images. The true color matrices are 3-dimensional matrices. The first two coordinates are the coordi

Algorithm for the function explaine: The algorithm for the function explaine is as shown:  Print a description of e, the exp function, and how to find the approximate va

Simplification Functions: There are numerous functions which work with expressions, and simplify the terms. Not all the expressions can be simplified, but the simplify functio

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

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

Algorithm for the function e: The algorithm for the function eoption is as shown: Use the menu function to show the 4 choices. Error-check (an error would take place

function imread: The function imread can read an image file, for illustration a JPEG (.jpg) file. The function reads color images into a 3-dimensional matrix. >> myimage1

Illustration of finding a sting: Let's enlarge this, and write a script which creates a vector of strings which are phrases. The outcome is not suppressed so that the string

Use polyval to evaluate the derivative at xder. This will be the % slope of the tangent line, "a" (general form of a line: y = ax + b). % 4. Calculate the intercept, b, of t