Question

In: Electrical Engineering

FOR THE FUNCTION CALLS OR OTHER DEFINED VARIABLES USING THE EXECUTIONS SUCH AS WHILE(), FOR(), IF(),...

FOR THE FUNCTION CALLS OR OTHER DEFINED VARIABLES USING THE EXECUTIONS SUCH AS WHILE(), FOR(), IF(), DO() AND ETC LOOPS OR CLASS INHERETANCES

WHAT ARE DIFFERENCES BETWEEN?
ARE THERE DIFFERENCES BETWEEN THE TYPES?
WHAT ARE THE TAKE AWAY POINTS OF THESE MENTIONED?

Solutions

Expert Solution

In while loop a condition is checked first, if the condition is true then a group of statement in the loop is executed while the condition is true. A condition is true when its result is non empty otherwise the condition is false. Here is an exmple of while loop calculating factorial of 10 in Matlab.

n = 10;
f = n;
while n > 1  % condition check
    n = n-1; % executing group of statemnt in while loop
    f = f*n;
end         % end of loop, condition is checked at the end of loop everytime.
disp(['n! = ' num2str(f)])

for loops are used to repeat a specified number of times, for loop consists of a condition check, number of times it must iterate, in while loop the the program would iterate asa long as the condition check results true but in for loop a fixed number is assingned to the number of iterations.

Step by increments of -0.2, and display the values.

for v = 1.0:-0.2:0.0
   disp(v)
end
1

    0.8000

    0.6000

    0.4000

    0.2000

     0

if, elseif, else loops execute statement if condition is true. Here is the syntax below:

if expression
    statement1
elseif expression
    statement2
else
    statement3
end

if the first expression is true then statement 1 would be execute, if the first expression is false then else expression would be checked. This loop allows for multiple condition checking.

In a do while loop first the block is executed, and then the condition is checked. If the condition is true the code within the block is executed again. This repeats until the condition becomes false. Whereas the while loop, tests the condition before the code within the block is executed. Here is the syntax for do while loop:

do {
   do_work();  
} while (condition); % condition check at the end.

Related Solutions

FOR THE FUNCTION CALLS OR OTHER DEFINED VARIABLES USING THE EXECUTIONS SUCH AS EX) WHILE(), FOR(),...
FOR THE FUNCTION CALLS OR OTHER DEFINED VARIABLES USING THE EXECUTIONS SUCH AS EX) WHILE(), FOR(), IF(), DO() AND ETC LOOPS OR CLASS INHERETANCES EX) something.something, etc. WHAT ARE DIFFERENCES BETWEEN? ARE THERE DIFFERENCES BETWEEN THE TYPES? EX) WHAT KIND OR TYPES OF VARIABLES CAN BE USED TO DEFINE IT? WHAT ARE THE TAKE AWAY POINTS OF THESE MENTIONED?
FOR THE FUNCTION CALLS OR OTHER DEFINED VARIABLES FOR THE EXECUTIONS OF YOUR CODING SUCH AS...
FOR THE FUNCTION CALLS OR OTHER DEFINED VARIABLES FOR THE EXECUTIONS OF YOUR CODING SUCH AS EX) WHILE(), FOR(), IF(), DO() AND ETC LOOPS OR CLASS INHERETANCES EX) something.something, etc. WHAT ARE THE DIFFERENCES OF THE RUN TIMES OF USING LOOPS AND CLASS FOR YOUR CODING? WHAT ARE THE ADVANTAGES OF EACH? PLEASE GIVE EXAMPLES WITH THE DETAILED COMMENTS HAND WRITING IS FINE AS LONG AS READABLE AND STRAIGHT FORWARD
A _______________ is defined as the set of local variables in a function that are kept alive after the function has returned.
Fill in the blanks in each of the following.A _______________ is defined as the set of local variables in a function that are kept alive after the function has returned.All JavaScript objects inherit the properties and functions (or also called methods) from their _______________ that is created using an object constructor function.The _______________ operator removes a given property from an object. (Note that the operator is a keyword, not a symbol.)A ____________________ is a web app that interacts with the...
Give four reasons why system calls are typically implemented using interrupts instead of function calls.
Give four reasons why system calls are typically implemented using interrupts instead of function calls.
9. Assume that the two variables AHE & AGE are related with each other while observing...
9. Assume that the two variables AHE & AGE are related with each other while observing the following condition: ???? = ?0 + ?1???? + ?? The GRETL estimate on the outcome of the above equation is given as hereunder: Model 1: OLS, using observations 1-500 Dependent variable: AHE Coefficient Std. Error t-ratio p-value const −4.66024 4.77501 −0.9760 0.3296 AGE 0.823615 0.159987 5.148 <0.0001 *** Mean dependent var 19.80938 S.D. dependent var 10.44739 Sum squared resid 51712.84 S.E. of regression...
Variables typically included in a multivariate demand function (other than the price and quantity of the...
Variables typically included in a multivariate demand function (other than the price and quantity of the item the demand function represents) are consumer tastes and preferences, the number of buyers, spendable (disposable) income, prices of substitute goods, prices of complementary goods, advertising expenditures, weather, and expectations. Recalling that the price of the item being considered is placed on the vertical axis, and the quantity on the horizontal axis, the other variables are termed demand shifters. Please answer the following questions...
Variables typically included in a multivariate demand function (other than the price and quantity of the...
Variables typically included in a multivariate demand function (other than the price and quantity of the item the demand function represents) are consumer tastes and preferences, the number of buyers, spendable (disposable) income, prices of substitute goods, prices of complementary goods, advertising expenditures, weather, and expectations.  Recalling that the price of the item being considered is placed on the vertical axis, and the quantity on the horizontal axis, the other variables are termed demand shifters.  Please answer the following questions about the...
Variables typically included in a multivariate demand function (other than the price and quantity of the...
Variables typically included in a multivariate demand function (other than the price and quantity of the item the demand function represents) are consumer tastes and preferences, the number of buyers, spendable (disposable) income, prices of substitute goods, prices of complementary goods, advertising expenditures, weather, and expectations. Recalling that the price of the item being considered is placed on the vertical axis, and the quantity on the horizontal axis, the other variables are termed demand shifters. Please answer the following questions...
Variables typically included in a multivariate supply function (other than the price and quantity of the...
Variables typically included in a multivariate supply function (other than the price and quantity of the item the supply function represents) are prices of other goods that use similar input resources for production, the number of suppliers, techniques of production, taxes and subsidies, prices of input resources, weather, and expectations. Please answer the following questions about the affect changes in other variables might have on the supply of the item. These changes will either cause supply to increase (shift right)...
Variables typically included in a multivariate supply function (other than the price and quantity of the...
Variables typically included in a multivariate supply function (other than the price and quantity of the item the supply function represents) are prices of other goods that use similar input resources for production, expectations, the number of suppliers, techniques of production, taxes and subsidies, and prices of input resources, weather.  Please answer the following questions about the affect changes in other variables might have on the supply of the item.  These changes will either cause supply to increase (shift right) or decrease...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT