Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following exercises are meant to be answered by few lines of MATLAB code; mo

ID: 3804613 • Letter: T

Question

The following exercises are meant to be answered by few lines of MATLAB code; most of them could be expressed in a single line of code or command. The command may be involved (i.e., it may use a number of parentheses or calls to functions) but can, in essence, be solved by the execution of a single command. If the problem is too complicated, feel free to break it up over two or more lines and later to collapse it into a single line.

6. Give the following commands to create an array called F:

>> randn('seed',123456789)

>> F = randn(5,10);

a. Compute the mean of each column and assign the results to the elements of a vector called avg.

b. Compute the standard deviation of each column and assign the results to the elements of a vector called s.

Explanation / Answer

There are two primary classifications of loops:

condition-controlled loops

Repeat one or more statements while some condition is true.

In general, when the loop begins, you do not know how many times it will repeat.

A condition-controlled loopin MATLAB is called a while loop.

count-controlled loops

Repeat one or more statements for a fixed number of times.

In general, when the loop begins, you know how many times it will repeat.

A count-controlled loop in MATLAB is called a for loop.

Most loops require a loop control variable that must be initialized, tested, and modified (ITM) to make the loop operate properly.

B. The for loop

The for loop has the following syntax:

for <loop control variable> = <vector expression>
     <one or more statements>
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote