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

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

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)

Sorting Vectors of structures: Whenever working with vector of structures, it is very common to sort based on a particular field within the structures. For illustration, recal

A matlab function to calculate filter order

Uses of Function handles: The Function handles can also be generated for functions other than anonymous functions, both built-in & user-defined functions. For illustration, th

IS Functions for Strings: There are many functions for strings, that return logical true or false. The function isletter returns the logical true when the character is a lette

Illustration of Matrix solutions: For illustration, consider the three equations below with 3unknowns x 1 ,x 2 , and x 3 : We can write this in the form Ax = b here A

Structures: The Structures are data structures which group together values which are logically related in what are known as the fields of structure. The benefit of structures

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