Evaluating a string, MATLAB in Engineering

Assignment Help:

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


Related Discussions:- Evaluating a string

Use of built-in colormaps - image processing, Use of built-in colormaps: ...

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

Function issorted - set operations, Function issorted - set operations: ...

Function issorted - set operations: The function issorted will return 1 for logical true when the argument is sorted in ascending order (minimum to maximum), or 0 for false wh

Function cirarea - anonymous functions, Function cirarea - Anonymous functi...

Function cirarea - Anonymous functions: The function handle name is cirarea. The one argument is passed to the input argument radius. The body of the function is an expression

Passing structures to functions, Passing Structures to Functions: The ...

Passing Structures to Functions: The whole structure can be passed to a function, or separate fields can be passed. For illustration, here are the two distinct versions of a f

Use of nested if-else statements, Use of Nested if-else statements: By...

Use of Nested if-else statements: By using the nested if-else to select from among the three possibilities, not all the conditions should be tested. In this situation, if x is

Distributed computing on linux cluster, i want to run 4 instances of my mat...

i want to run 4 instances of my matlab code on 4 processor cores. im executing the job from head node. i created a parallel job and assigned number of workers. but i don''t get bac

Implementation of binary search, Implementation of binary search: The ...

Implementation of binary search: The binary search can be implemented as a recursive function. The recursive function below also implements this binary search algorithm. It re

Creating the structure variables, Creating the structure Variables: Cr...

Creating the structure Variables: Creating a structure variable can be accomplished by simply storing the values in fields by using assignment statements, or by using the stru

Illustration of vectors of structures, Illustration of Vectors of structure...

Illustration of Vectors of structures: In this illustration, the packages are vector which has three elements. It is shown as a column vector. Each and every element is a stru

Technique to creating this structure, Technique to creating this structure:...

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

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd