For more examples and details, visit: http://matrixlab-examples.com/tower-of-hanoi-algorithm.html
The objective of the Towers of Hanoi puzzle is to move all of the disks from tower A to tower C.
There are only Two Easy Rules:
- Only one disk can be moved at a time and it can only be the top disk of any tower.
- Disks cannot be stacked on top of smaller disks.
We’re going to solve the puzzle using the recursion method.
Recursion is a computer programming technique that involves the use of a procedure that calls itself one or several times until a specified condition is met.
In this presentation you can find the details to solve the puzzle in Matlab (or GNU-Octave).
Matlab Tutorials and Examples:
http://www.matrixlab-examples.com
To download a Matlab clone --
GNU-OCTAVE (UPM VERSION)
UPM = Universidad Politécnica de Madrid
This is a graphic version and has been tested in Win 7 and Win 8.
http://mat.caminos.upm.es/octave/descargas/r8.2/
For other versions or platforms, you have to refer to the GNU Octave Project directly:
https://www.gnu.org/software/octave/
To use the online calculator, go to:
http://matrixlab-examples.com/quadratic-equation-solver.html
I'm gonna show you how to use the quadratic formula.
This is the general form of quadratic equations. You have to take care of 3 coefficients: a, b and c. The formula produces two solutions to each problem.
The quadratic coefficient is called a, the linear coefficient is called b, and the free term is called c.
In this example, our quadratic coefficient is 2, our linear coefficient is 3, and the free term is 1.
The first solution is -.5 and the second solution is -1.
Now, let's use the calculator that we have for this purpose. We just fill in the blanks, first a, then b and finally c. We can see the two solutions, in this case -0.5 and -1.
And we can explore solutions for other coefficients, even for complex solutions.
Thank you for watching!
For more details and examples, visit: http://www.matrixlab-examples.com/break-statement.html
Break and Continue Statements. Concepts, examples and code in Matlab.
The break statement terminates the execution of a for or while loop. Statements in the loop after the break statement do not execute. In nested loops, break exits only from the loop in which it occurs. Control passes to the statement that follows the end of that loop.
The continue statement temporarily interrupts the execution of a program loop, skipping any remaining statements in the body of the loop for the current pass. It continues within the loop for as long as the stated for or while condition holds true.
More examples on how to control the flow of the code: http://matrixlab-examples.com/matlab-code-3.html