leftimage for poohprod.ru

Matlab Code - Loops, branches, and control-flow


The MATLAB code has its own instructions for flow of control statements like 'for-loops', 'while' and 'if-elseif' branching. See details and examples...

For loop
The for loop repeats a group of statements a fixed, predetermined number of
times. A matching end delineates the statements...

Application of Nested Iterations (Matrix Multiplication)
We show a script in Matlab code that performs a matrix multiplication step-by-step. The algorithm displays all the elements being considered for

the multiplication and shows how the resulting matrix is being formed in each step. Obviously, Matlab can do it with just one operation, but...

Pascal's Triangle
Let's calculate the coefficients of binomial expansions...

Armstrong Numbers
An Armstrong number (sometimes called also narcissistic numbers) of three digits is an integer such that the sum of the cubes of its digits equals the number itself. For example, 407 is an Armstrong number since 4^3 + 0^3 + 7^3 = 407...

While loop
The while loop repeats a group of statements an indefinite number of times
under control of a logical condition. A matching end closes the statements...

Square Root (using while-loops)
We’ll explore a square root algorithm as an excuse to use while-loops in our numerical software. We’re not going to use the built-in function ‘sqrt’...

Collatz Sequence (while-loops)
The Collatz conjecture is an unsolved conjecture in mathematics. This conjecture is also known as 3n + 1 or the Syracuse problem; the sequence of numbers involved is referred to as the hailstone sequence...

If... elseif... else... end (branches or decisions)
The if statement evaluates a logical expression and executes a group of
statements when the expression is true. The optional elseif and else keywords provide for the execution of alternate groups of statements...

Break (exit from loops)
The break statement lets you exit early from a for or while loop. In nested
loops, break exits from the innermost loop only...

Control Flow: for-loops, if-statements, break (in a Matrix Inversion)
This program performs the matrix inversion of a square matrix step-by-step. The inversion is performed by a modified Gauss-Jordan elimination method. We start with an arbitrary square matrix and a same-size identity matrix (all the elements along its diagonal are 1)...

Switch-Case-Otherwise
The switch statement executes groups of statements based on the value of a variable or expression. The keywords case and otherwise delineate the groups...

Piecewise Functions
A piecewise function (or piecewise-defined function) is a function whose definition changes depending on the value of the independent variable...

Equation of Straight lines
We'll develop three functions to work out equations of straight lines in Matlab with different approaches...

From 'Matlab Code' to home

To 'Matlab Examples'

Search / ToC

Linear Algebra

Top




footer for matlab code - flow control page








































Related pages


calculating angles between vectorsmatlab push buttonbisection matlabbinary to octal convertpiecewise functions in matlabcapacitor charging and discharging graphfibonacci calculator formuladouble integrals calculatorfibonacci number generatortable of ascii codesascii char mapfibonacci for looploops in matlabhex to binary conversion methodtutorials on matlabgraph step function onlineconverting polar coordinates to cartesianamortization tables for mortgagedecimal to octal tableascii to binary tabletower of hanoi game solution2d interpolation matlabprogram to convert binary to decimalbinary to ascii conversion tableimpulse function matlabhow to change from binary to decimalhow to solve integrals in matlabbilinear interpolation examplepower factor correction capacitorshow to calculate scrap valueformula for charging a capacitorformula of infinite geometric serieshow to find the salvage valuesquare feet to inches calculatordefine salvage valuegaussian curve formulacalculating half life formularange of piecewise functionswriting matrices in matlabgauss jordan calculator onlinedensity plot matlabmatlab switch case exampleif statements in matlabhow to calculate depreciation rate formulalogic of fibonacci seriesuniformly distributed random numbers matlabbisectional methodmaclaurin series cosxcount bmi formulaexamples of fibonacci sequencehow do you calculate bmi manuallybinary to decimal programconvert binary to octaltransients in rc circuitsdist matlabinterest rate compounded continuously calculatoreir calculationsolve matrix equation matlabexamples of decimal to binaryprime factorization examplepiecewise function graphsmultiple integral calculatorhypoteneuse calculatorsolving equation in matlaboctal numberingwhat is meant by salvage valuepoisson distribution calculator onlinesquare root approximation formulainterest amortization tablesoctal to decimal conversion