Looping statements, MATLAB Programming

Looping Statements:

Consider the problem of computing the area of a circle with radius of 0.3 centimeters-a MATLAB program certainly is not required to do that; you would use your calculator rather than, and punch in π* 0.3 2. Though, if a table of circle areas is preferred, for radii ranging from 0.1 centimeters to 100 centimeters in steps of 0.05 (example 0.1, 0.15, 0.2, etc.), it would be very tiresome to use a calculator and write it all down. This is one of the huge uses of a computer-the ability to repeat a process such as this.

This section will cover statements in MATLAB which allow the other statement(s) to be repeated. The statements which do this are known as the looping statements, or loops. There are two basic types of loops in the programming: counted loops, and conditional loops. The counted loop is one which repeats statements in a specified number of times (example, ahead of time it is known how many times the statements are to be repeated). In a counted loop, for illustration, you might tell 'repeat these statements 10 times.' The conditional loop also repeats the statements, but ahead of time it is not known how many times the statements will require to be repeated.

With a conditional loop, for illustration, you might tell 'repeat these statements until this condition becomes false.' The statement(s) which are repeated in any loop are known as the action of the loop.

There are two different loop statements in the MATLAB: the for statement and the while statement. In practice, the for statement generally used as the counted loop, and while is used as the conditional loop. To keep it easy, that is how they will be represented here.

Finally, though loops are extremely helpful in most programming applications, in MATLAB they are often not necessary, particularly when dealing with the arrays. The concept of vectorizing will be introduced, that is the term used in MATLAB for rewriting code which was written by using loops in a traditional programming language to matrix operations in the MATLAB.

Posted Date: 10/19/2012 3:29:24 AM | Location : United States

Related Discussions:- Looping statements, Assignment Help, Ask Question on Looping statements, Get Answer, Expert's Help, Looping statements Discussions

Write discussion on Looping statements
Your posts are moderated
Related Questions
A file houseafford.dat stores on its three lines years, median incomes and median home prices for a city. The dollar amounts are in thousands. For example, it might look like this:

A filter described by the equation:    y(n) = x(n) + x(n-1) + 0.9 y(n-1) - 0.81 y(n-2) (a) Find the transfer function H(z) for the filter and find the poles and zeros of the fil

How do you write a programme that asks the user for a number between 1 and 1000 and calculates the sum of its digits?

The Programming Concept: In most of the programming languages, random function returns a real number; therefore the real number would then have to be rounded to produce a rand

The circuit diagram of an active filter is shown below. (a) Determine an expression for the transfer function of the filter. (b) Hence find an expression for the frequency res

A band pass FIR filter is required to pass frequencies from 5KHz to 8KHz, using a sample rate of 40K i) Explain how this would map to normalization sampling frequencies in radia

Explain how the wavelet transform based on the real biorthogonal "decomposition" wavelet bior 1.5 (the wavelet shape by typing waveinfo ('bior') at the MATLAB command prompt) can

The pressure radiated by a column of in-phase monopole sources may be expressed as: Create a model (spreadsheet / MATLAB etc) for a 6 element column, where d=0.2m . Figure

A 12-point sequence is x (n) defined as x(n) = { 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1}. Write MATLAB programs to (a) Determine the DFT X (k) of x(n) and plot (using stem function)

RECOGNIZER and TRANSLATOR: i want to recognized devanagari word using matlab. I have done it using template matching. but i am not get devanagari word at the output. But get speci