Chapter 4: Programming with MATLAB - FET
Chapter 4: Programming with MATLAB - FET Chapter 4: Programming with MATLAB - FET
4-19 The following statements if logical expression 1 if logical expression 2 statements end end can be replaced with the more concise program if logical expression 1 & logical expression 2 statements end The elseif Statement The general form of the if statement is if logical expression 1 statement group 1 elseif logical expression 2 statement group 2 else statement group 3 end The else and elseif statements may be omitted if not required. However, if both are used, the else statement must come after the elseif statement to take care of all conditions that might be unaccounted for. Z.R.K
For example, suppose that y = ln(x) for x > 10, y = sqrt(x) for 0 = 0 y = sqrt(x) else y = exp(x) - 1 end Flowchart illustrating nested if statements. Figure 4.4–4 Z.R.K 4-20 More See pages 205-208.
- Page 1 and 2: UNIVERSITY OF JORDAN Faculty of Eng
- Page 3 and 4: 4-3 Components of an Algorithm •
- Page 5 and 6: 4-5 Steps for developing a computer
- Page 7 and 8: Effective documentation can be acco
- Page 9 and 10: Flowcharts are useful for developin
- Page 11 and 12: To locate a runtime errors, try the
- Page 13 and 14: Order of precedence for operator ty
- Page 15 and 16: Logical function ischar(A) isempty(
- Page 17 and 18: The if and else Statement The if st
- Page 19: Instead, consider what happens if w
- Page 23 and 24: 4-22 Strings and the input Statemen
- Page 25 and 26: for Loops A simple example of a for
- Page 27 and 28: The continue Statement The followin
- Page 29 and 30: while Loops The while loop is used
- Page 31 and 32: 4-30 A simple example of a while lo
- Page 33 and 34: The switch Structure The switch str
- Page 35 and 36: The Editor/Debugger containing two
- Page 37: End of Chapter 4 Problems Page 241
For example, suppose that<br />
y = ln(x) for x > 10,<br />
y = sqrt(x) for 0 = 0<br />
y = sqrt(x)<br />
else<br />
y = exp(x) - 1<br />
end<br />
Flowchart illustrating nested<br />
if statements. Figure 4.4–4<br />
Z.R.K<br />
4-20 More See pages 205-208.