Matlab Function

Matlab® provides very useful tools to calculate different mathematical operations. One of them is for the calculation of the polygamma functions. ‘Polygamma functions’ is a very important aspect of advanced mathematics. You can find detailed information about the polygamma functions from this link.

A function handle is a MATLAB value that provides a means of calling a function indirectly. You can pass function handles in calls to other functions (often called function functions ). You can also store function handles in data structures for later use (for example, as Handle Graphics callbacks). Most MATLAB functions, like sin, cos, log, and many others, work regardless of the size of the input. If A is a numeric array of any size, then B=sin(A) is another array such that B(i,j) sin(A(i,j)) Example This creates a 20-by-4-by-2 3D array called A and then creates another array with the same dimensions using the exponential function.

  1. S = struct (field,value) creates a structure array with the specified field and value. The value input argument can be any data type, such as a numeric, logical, character, or cell array. If value is not a cell array, or if value is a scalar cell array, then s is a scalar structure. For instance, s = struct ('a', 1 2 3) creates a 1-by-1.
  2. MATLAB is the easiest and most productive computing environment for engineers and scientists. With math, graphics, and programming, it's designed for the way you think and the work you do. Learn more about MATLAB.
  3. MATLAB syntax is quite peculiar compared to other programming languages. We can return one or more values from a function. We can also pass one or more arguments/variables while calling a function. MATLAB functions must be defined in separate files and function name must match with the file name.

YOU CAN LEARN MatLab® IN MECHANICAL BASE; Click And Start To Learn MatLab®!

Polygamma functions are calculated with the ‘psi()’ command in Matlab®. Here we explained how to calculate polygamma functions in Matlab® with the ‘psi()’ command. You can try this command in your Matlab® software.

How To Use The ‘psi()’ Command In MatLab®?

As you see in the programming example above, you need to enter two inputs inside the ‘psi()’ command in Matlab® to calculate the polygamma function. The only requirement is that the first term must be bigger than 4.

The general expression of the polygamma function is like the above. The first term that you entering inside the brackets is the ‘m’ above. And the second term is the ‘z’. Polygamma function is calculated with these values in Matlab®.

Conclusion

As you understand that the calculation of the polygamma functions in Matlab® is very simple with the ‘psi()’ command.

Do not forget to leave your comments and questions below about the use of the ‘psi()’ command in Matlab® below.

If you want further coding examples about the ‘psi()’ command in Matlab®, inform us in the comments.

This article is prepared for completely educative and informative purposes. Images used courtesy of Matlab®

  • Matlab Tutorial
  • MATLAB Advanced
  • MATLAB Useful Resources
  • Selected Reading

So far, we have seen that all the examples work in MATLAB as well as its GNU, alternatively called Octave. But for solving basic algebraic equations, both MATLAB and Octave are little different, so we will try to cover MATLAB and Octave in separate sections.

We will also discuss factorizing and simplification of algebraic expressions.

Solving Basic Algebraic Equations in MATLAB

The solve function is used for solving algebraic equations. In its simplest form, the solve function takes the equation enclosed in quotes as an argument.

For example, let us solve for x in the equation x-5 = 0

MATLAB will execute the above statement and return the following result −

You can also call the solve function as −

MATLAB will execute the above statement and return the following result −

You may even not include the right hand side of the equation −

MATLAB will execute the above statement and return the following result −

If the equation involves multiple symbols, then MATLAB by default assumes that you are solving for x, however, the solve function has another form −

where, you can also mention the variable.

For example, let us solve the equation v – u – 3t2 = 0, for v. In this case, we should write −

Function

MATLAB will execute the above statement and return the following result −

Solving Basic Algebraic Equations in Octave

The roots function is used for solving algebraic equations in Octave and you can write above examples as follows −

For example, let us solve for x in the equation x-5 = 0

Octave will execute the above statement and return the following result −

You can also call the solve function as −

Octave will execute the above statement and return the following result −

Solving Quadratic Equations in MATLAB

The solve function can also solve higher order equations. It is often used to solve quadratic equations. The function returns the roots of the equation in an array.

The following example solves the quadratic equation x2 -7x +12 = 0. Create a script file and type the following code −

When you run the file, it displays the following result −

Solving Quadratic Equations in Octave

The following example solves the quadratic equation x2 -7x +12 = 0 in Octave. Create a script file and type the following code −

When you run the file, it displays the following result −

Solving Higher Order Equations in MATLAB

The solve function can also solve higher order equations. For example, let us solve a cubic equation as (x-3)2(x-7) = 0

MATLAB will execute the above statement and return the following result −

In case of higher order equations, roots are long containing many terms. You can get the numerical value of such roots by converting them to double. The following example solves the fourth order equation x4 − 7x3 + 3x2 − 5x + 9 = 0.

Create a script file and type the following code −

When you run the file, it returns the following result −

Please note that the last two roots are complex numbers.

Solving Higher Order Equations in Octave

The following example solves the fourth order equation x4 − 7x3 + 3x2 − 5x + 9 = 0.

Create a script file and type the following code −

When you run the file, it returns the following result −

Solving System of Equations in MATLAB

The solve function can also be used to generate solutions of systems of equations involving more than one variables. Let us take up a simple example to demonstrate this use.

Let us solve the equations −

5x + 9y = 5

Pixinsight core keygen. 3x – 6y = 4

Create a script file and type the following code −

When you run the file, it displays the following result −

In same way, you can solve larger linear systems. Consider the following set of equations −

x + 3y -2z = 5

3x + 5y + 6z = 7

2x + 4y + 3z = 8

Solving System of Equations in Octave

We have a little different approach to solve a system of 'n' linear equations in 'n' unknowns. Let us take up a simple example to demonstrate this use.

Let us solve the equations −

5x + 9y = 5

Matlab

3x – 6y = 4

Such a system of linear equations can be written as the single matrix equation Ax = b, where A is the coefficient matrix, b is the column vector containing the right-hand side of the linear equations and x is the column vector representing the solution as shown in the below program −

Create a script file and type the following code −

When you run the file, it displays the following result −

In same way, you can solve larger linear systems as given below −

x + 3y -2z = 5

3x + 5y + 6z = 7

2x + 4y + 3z = 8

Expanding and Collecting Equations in MATLAB

The expand and the collect function expands and collects an equation respectively. The following example demonstrates the concepts −

When you work with many symbolic functions, you should declare that your variables are symbolic.

Create a script file and type the following code −

When you run the file, it displays the following result −

Expanding and Collecting Equations in Octave

You need to have symbolic package, which provides expand and the collect function to expand and collect an equation, respectively. The following example demonstrates the concepts −

When you work with many symbolic functions, you should declare that your variables are symbolic but Octave has different approach to define symbolic variables. Notice the use of Sin and Cos, which are also defined in symbolic package.

Create a script file and type the following code −

When you run the file, it displays the following result −

Factorization and Simplification of Algebraic Expressions

Matlab Function Dot

The factor function factorizes an expression and the simplify function simplifies an expression. The following example demonstrates the concept −

Matlab Function

Matlab Function Call

Example

Create a script file and type the following code − Autocad lt 2007 keygen crack club.

When you run the file, it displays the following result −

Matlab Function Definition