Expanding a function, MATLAB in Engineering

Expanding a function:

The expand function will multiply out terms, and factor will do the opposite:

>> expand((x+2)*(x-1))

ans =

x^2 x-2

>> factor(ans)

ans =

(x 2)*(x-1)

 

The function subs will replace a value for the symbolic variable in an expression. For illustration,

>> myexp = x^3 + 3*x^2 - 2

myexp =

x^3 3*x^2-2

>> x = 3;

>> subs(myexp,x)

ans =

       52

 

With symbolic math, a MATLAB works by the default with rational numbers means that the outcomes are kept in fractional forms. For illustration, executing the addition 1/3 + 1/2 would generally answer in a double value:

>> 1/3 + 1/2

ans =

       0.8333

Though, by making the expression symbolic, the outcome is symbolic also. Any numeric function (example, double) could modify that:

>> sym(1/3 + 1/2)

ans =

5/6

>> double(ans)

ans =

       0.8333

 

Posted Date: 10/22/2012 4:36:13 AM | Location : United States







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

Write discussion on Expanding a function
Your posts are moderated
Related Questions
Replacing a string - function strrep: The function strrep finds all the occurrences of a substring within the string, and substitutes them with a new substring. The order of a

Finding a sting - function strfind: The function strfind does necessarily similar thing, except that the order of the arguments does make dissimilarity. The common form is str

Subfunctions: Though, it is possible to have more than one function in a given M-file. For illustration, if one function calls the other, the first function would be the prima

Indexing into Vectors of structures: Frequently, when the data structure is a vector of structures, it is essential to iterate through the vector in order by various fields. F

Variable Scope: The scope of any of variable is the workspace in which it is valid. The workspace generated in the Command Window is known as the base workspace. As we know

Illustration of Variable scope: Running this function does not add any of variables to the workspace, as elaborated: >> clear >> who >> disp(mysum([5 9 1]))

1. Write a MATLAB function (upperTriangle) using the functions you previously created to convert a matrix to upper triangular form. Start with row 1, column1. Find the row that has

Expanding a function: The expand function will multiply out terms, and factor will do the opposite: >> expand((x+2)*(x-1)) ans = x^2 x-2 >> factor(ans)

Function used in binary search: The function below implements this binary search algorithm. It receives two arguments: the sorted vector and a key (on the other hand, the func

str2num function - String: The function str2num does the opposite; it takes the string in which a number is stored and converts it to the type double: >> num = str2num('123.