ENGR 111 Test 2: Ch 6-

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

1. Items within parentheses are evaluated first. 2. not (negation) is evaluated next. For example, ~ a & b evaluates as (~a) & b. 3. and is evaluated after not. Thus a & b | c evaluates as (a & b) | c. The expression will always be true if both and and b are true, for example. 4. Last to be evaluated is or. 5. If more than one operator of equal precedence could be evaluated, evaluation occurs left to right. Thus, a | b | c evaluates as (a | b) | c.

( ) ~ & | left-to-right

Ex: temps = [ 15, 37, 21, 40 ]; tempsColdLocs = temps < 32 tempsCold = temps (tempsColdLocs)

(tempColdLogs = [1, 0, 1, 0]) ans: [15, 21]

To add two arrays: to subtract two arrays: to multiply two arrays: to divide two arrays: to exponent two arrays:

+ - .* (period in front) ./ (period in front) .^ (period in front)

If myVal is initially 0, what is myVal's value after the following? if (myVal ~= 0) myVal = 5; end myVal = myVal + 1;

1

Nested loop ex: for xVal = 1:12 for yVal = 1:12 fprintf('%d * %d = %d\n', xVal, yVal, xVal*yVal); end fprintf('\n'); % print blank line between each xVal end

1 * 1 = 1 1 * 2 = 2 1 * 3 = 3 1 * 4 = 4 1 * 5 = 5 1 * 6 = 6 1 * 7 = 7 1 * 8 = 8 1 * 9 = 9 1 * 10 = 10 1 * 11 = 11 1 * 12 = 12 2 * 1 = 2 2 * 2 = 4

Given metersRun = 800, metersBiked = 2000, and kmDriven = 0.8 are floating-point numerical variables. 1. The comparison kmDriven == metersRun should be avoided. 2. The comparison metersRun == metersBiked should be avoided. 3. If kmDriven2 is 0.80000001, then abs(kmDriven - kmDriven2) < 0.00001 would return true, meaning the numbers are essentially equal. 4. If kmDriven2 is 0.9, then abs(kmDriven - kmDriven2) < 0.00001 would return true, meaning the numbers are essentially equal. 5. An appropriate comparison method is abs(metersRun, 900) < 0.0001. 6. An appropriate comparison method is abs(kmDriven - 0.5) < 1. 7. abs(kmDriven - 0.5) < 0.0001 would be OK, but abs(0.5 - kmDriven) < 0.0001 would not due to the negative result.

1. True 2. True 3. True 4. Flase (The difference is 0.1, which is NOT less than 0.00001, so the result is false (meaning NOT equal; they are NOT close enough).) 5. False (The abs function has one input. The input should be metersRun - 900 (replace comma with minus).) 6. False (The threshold is too large for the numbers involved. 0.8 - 0.5 would be 0.3, which is less than 1, so the result is true, meaning the numbers are considered equal -- certainly not the programmer's intent.) 7. False (The absolute value function makes the result independent of the ordering. 0.5 - 0.8 is -0.3, whose absolute value is 0.3. 0.3 is not less than 0.0001, so the result is false, meaning the numbers would NOT be considered equal, as desired.)

If myVal is initially 99, what is its value after the following? if (myVal <= 99) myVal = myVal + 1; end myVal = myVal + 10;

110

What is the output of the following code? i1 = 1; while (i1 < 19) i2 = 3; while (i2 <= 9) fprintf('%d%d ', i1, i2); i2 = i2 + 3; end i1 = i1 + 10; end

13 16 19 113 116 119

What is the value of num after the following loop terminates? num = 1; while( num < 10 ) num = 2 * num; end

16

What is output x=5; y=18; while (y >= x) fprintf('%d ',y); y = y - x; end

18 13 8

What size is myArray = [4, 5, 9]? Express answer as AxB.

1x3

If myVal is initially -2, what is myVal's value after the following? if (myVal <= 0) myVal = 5; end myVal = myVal + 1;

6

Fix: >> liters = 0.1 + 0.2 + 0.3 liters = 0.6000 >> liters = liters - 0.6 % Results in something very close to 0, but not 0 liters = 1.1102e-16 >> isEmpty = (liters == 0) % so this comparison yields false isEmpty = 0

>> liters = 0.1 + 0.2 + 0.3; >> liters = liters - 0.6 % Results in something very close to 0, but not 0 liters = 1.1102e-16 >> isEmpty = ( abs(liters - 0) < 0.00001 ) % Close enough, so yields true isEmpty = 1

can be only true or false

Boolean Ex: isLarge = true isHeavy = false

involves using a construct that directs execution to one list of statements (also referred to as a code block) or another list of statements based on the value of a logical expression that evaluates to either true or false.

Branching

An array whose elements may be of different types

inhomogeneous array

The program will evaluate the switch statement's expression, compare the resulting value with the expression for each _____, executing the first matching case's statements, and then jumping to the end. If no case matches, then the _____ case's statements are executed.

Case Otherwise

An alternative one-dimensional array is a ____________ whose N elements are organized as 1 column of N rows. Note that semicolons separate the elements, rather than commas. In the context of creating an array, the semicolon ';' separates rows, just as commas separate different array elements in a single row.

Column array Ex: columnArray = [element1; element2; element3; .... ; elementn];

Sometimes the programmer has multiple if statements in sequence, which looks similar to but has a very different meaning than cascaded if-elseif-else statements. Consider the following code: Ex: usrAge = input('Enter age: '); % Note that more than one "if" statement can execute if (usrAge < 16) fprintf('You are too young to drive.\n'); end if (usrAge >= 16) fprintf('You are old enough to drive.\n'); end if (usrAge >= 18) fprintf('You are old enough to vote.\n'); end if (usrAge >= 25) fprintf('Most car rental companies will rent to you.\n'); end if (usrAge >= 35) fprintf('You can run for president.\n'); end

Command Window for following ages: Enter age: 12 You are too young to drive. ... Enter age: 27 You are old enough to drive. You are old enough to vote. Most car rental companies will rent to you. ... Enter age: 90 You are old enough to drive. You are old enough to vote. Most car rental companies will rent to you. You can run for president.

While loop that counts iterations Ex: initSavings = 10000; interestRate = 0.05; fprintf('Initial savings of $%d\n', initSavings); fprintf('at %f yearly interest.\n\n', interestRate); years = input('Enter years: '); i = 1; savings = initSavings; while (i <= years) fprintf(' Savings in year %d is %f\n', i, savings); savings = savings + (savings * interestRate); i = i + 1; end

Command Window: Enter years: 5 Savings in year 1 is 10000.000000 Savings in year 2 is 10500.000000 Savings in year 3 is 11025.000000 Savings in year 4 is 11576.250000 Savings in year 5 is 12155.062500

automatically constructs a numeric row array just by specifying a starting value, an increment value(addition of that number to each element), and a terminating value, with those values separated by colons.

Double colon operator Ex: myArray = [5:1:9] yields array [5, 6, 7, 8, 9] Ex: myArray = [firstValue : incrementValue : terminatingValue]; myArray = [firstValue : terminatingValue]; % Increment is 1

What would command window look like for Past year 1900? Ex: userYear = input('Enter a past year (neg. for B.C.): '); consYear = 2020; % Year being considered numAnc = 2; % Approx. ancestors in considered year yearsPerGen=20; % Approx. years per generation while (consYear >= userYear) fprintf('Ancestors in %d: %d\n',consYear,numAnc); numAnc = 2 * numAnc; % Each ancestor had two parents consYear = consYear - yearsPerGen; % Go back 1 generation end

Enter a past year (neg. for B.C.): 1900 Ancestors in 2020: 2 Ancestors in 2000: 4 Ancestors in 1980: 8 Ancestors in 1960: 16 Ancestors in 1940: 32 Ancestors in 1920: 64 Ancestors in 1900: 128

What would command window say for 19 and 28: priceL25 = 4800; % Age less than 25 price25U = 2200; % Age 25 and up age = input('Enter age: '); if (age < 25) price = priceL25; else price = price25U; end fprintf('Annual price: $%d\n', price);

Enter age: 19 Annual price: $4800 ... Enter age: 28 Annual price: $2200

What does command window state: userVal = input('Enter an integer: '); absVal = userVal; if (absVal < 0) fprintf('Converting to positive.\n'); absVal = absVal * -1; end fprintf('The absolute value of %d is %d.\n', userVal, absVal);

Enter an integer: -3 Converting to positive. The absolute value of -3 is 3. ... Enter an integer: 40 The absolute value of 40 is 40.

What would this show on command window? usrNum = input('Enter positive number (<0 to quit): '); totalSum = 0; while (usrNum >= 0) totalSum = totalSum + usrNum usrNum = input('Enter positive number (<0 to quit): '); end

Enter positive number (<0 to quit): 1 totalSum = 1 Enter positive number (<0 to quit): 4 totalSum = 5 Enter positive number (<0 to quit): -1

Fibonacci code, what would this show on command window? curFib = 1; prevFib = 0; nextFib = 1; % initialize variables fprintf('Fibonacci sequence: 0 1 '); while (nextFib < 10) prevFib = curFib; % F(n-1) = F(n) curFib = nextFib; % F(n) = F(n+1) fprintf('%d ', curFib); % output current Fibonacci number nextFib = curFib + prevFib; % F(n+1) = F(n) + F(n-1) end fprintf('\n');

Fibonacci sequence: 0 1 1 2 3 5 8

An array whose elements are all the same type

Homogenous array

can include relational operators (such as < or ==) and logical operators (such as &, |,or ~).

Logical expression

compares two logical variables to reach a logical decision that results in a logical variable (i.e. either true or false).

Logical operator

Commonly, a loop should iterate a specific number of times, such as 10 times. A variable is used to count the number of iterations, called a ________.

Loop variable Ex: i = 1; while (i <= N) % Loop body statements go here i = i + 1; end (Iterated N times using an integer loop variable i)

are loops in which one loop appears as part of the body of another loop. The ____________ are commonly referred to as the inner loop and outer loop.

Nested loops

This material's initial focus is on arrays whose elements are all numbers of the same type (such as doubles).

Numerica Array

firstFive = 1:5; % First five integers Primes5 = [false, true, true, false, true] Comps5 = ~Primes5 % Composite numbers are not primes PowOf2 = [true, true, false, true, false]; % Integer powers of 2 PrimeAndPowOf2 = Primes5 & PowOf2 % Prime and power of 2 PrimeOrPowOf2 = Primes5 | PowOf2 % Prime or power of 2 PrimeXorPowOf2 = xor(Primes5,PowOf2) % Prime or power of 2 but not both

Primes5 = 0 1 1 0 1 Comps5 = 1 0 0 1 0 PrimeAndPowOf2 = 0 1 0 0 0 PrimeOrPowOf2 = 1 1 1 1 1 PrimeXorPowOf2 = 1 0 1 1 1

outputs the size of each dimension of the function's input array

The size function

An array may consist of just one dimension, such an array is sometimes called a ____________, which is just a single list of items arranged either as one row or as one column. ex: [x y z]

Vector

What does vals equal after executing vals = xor([1, 1, 0], [0, 1, 0])?

[1, 0, 0] (cant be both)

What new array does vals = linspace(3,9,4) create?

[3, 5, 7, 9]

And returns true if a and b are true, meaning both are true. Or returns true if a or b is true, meaning either is true (or both). Not negates or complements the value of a, returning true if a is false, and vice versa. Exclusive or returns true if a is true or b is true but not both, i.e., if exactly one of a or b is true. Also known as or xor (the x comes from eXclusive).

a & b and(a,b) a | b or(a,b) (squiggly)a not(a) xor(a,b)

1. Returns true if a and b are true, meaning both are true. 2. Returns true if a or b is true, meaning either is true (or both). 3. Negates or complements the value of a, returning true if a is false, and vice versa. 4. Returns true if a is true or b is true but not both, i.e., if exactly one of a or b is true. Known as exclusive or or xor (the x comes from eXclusive).

a & b (and(a,b)) a | b (or(a,b)) ~a (not(a)) xor(a,b)

Returns true if x is nonzero; otherwise, returns false.

any(x)

is one type of array operation that applies an arithmetic operation (+, -, *, /) involving a scalar to each element in the array. For example, myArray = myArray - 10 subtracts 10 from each element in myArray.

arithmetic array operation with a scalar

is an ordered sequence of items of a given data type ( like a grocery list or course roster, a programmer commonly needs to maintain an ordered sequence of items)

array

What would command window look like for this array n = 10; arryOfSqrs = [ ]; % Note the empty operator for i = 1:1:n arryOfSqrs = [arryOfSqrs, i^2]; end arryOfSqrs

arryOfSqrs = 1 4 9 16 25 36 49 64 81 10

What would command window look like for this array? n = 10; arryOfSqrs = []; % Note the empty operator for i = n:-1:1 arryOfSqrs = [arryOfSqrs, i^2]; end arryOfSqrs

arryOfSqrs = 100 81 64 49 36 25 16 9 4 1

Write a statement that assigns the first element of carWeights with 0

carWeights(1) = 0

cityPops = [17, 14, 13, 11, 10] cityPopsPast = cityPops * 0.8 cityPopsFuture = cityPops * 1.2 cityPopsGrowth = cityPopsFuture - cityPops cityPopsTopFiveSum = sum(cityPops)

cityPops = 17 14 13 11 10 cityPopsPast = 13.6000 11.2000 10.4000 8.8000 8.0000 cityPopsFuture = 20.4000 16.8000 15.6000 13.2000 12.0000 cityPopsGrowth = 3.4000 2.8000 2.6000 2.2000 2.0000 cityPopsTopFiveSum = 65

Ex of indexing an array: What would be on command window? cityPopulations = [17, 14, 13, 11, 10] topTwo = cityPopulations(1) + cityPopulations(2) cityPopulations(5) = 11

cityPopulations = 17 14 13 11 10 topTwo = 31 cityPopulations = 17 14 13 11 11

___________ two arrays into one array, wherein a new array is created by appending a second array's elements to the end of a first array's elements. __________[1, 2, 3] and [4, 5, 6] would thus yield [1, 2, 3, 4, 5, 6].

concatenate Ex: Given array1 = [1, 2, 3] and array2 = [4, 5, 6], concatenation is achieved as follows: arrayNew = [array1, array2].

Ex: dailyHours = [9, 8, 8, 0, 0, 9, 9.5]; dailyWage1 = dailyHours .* 10 dailyWage2 = dailyHours * 10 dailyWage3 = dailyHours / 10 hourlyWage = [10, 10, 10, 10, 10, 10, 10]; dailyWage4 = dailyHours .* hourlyWage

dailyWage1 = 90 80 80 0 0 90 95 dailyWage2 = 90 80 80 0 0 90 95 dailyWage3 = 0.9000 0.8000 0.8000 0 0 0.9000 0.9500 dailyWage4 = 90 80 80 0 0 90 95

Ex of relational operator: roomTemp = 27; outsideTemp = 33; cellarTemp = 15; decisionOne = roomTemp < cellarTemp decisionTwo = roomTemp == outsideTemp decisionThree = outsideTemp > cellarTemp decisionFour = cellarTemp ~= outsideTemp furnaceOff = (roomTemp < outsideTemp) Notice how there is no semicolon

decisionOne = 0 decisionTwo = 0 decisionThree = 1 decisionFour = 1 furnaceOff = 1

Row array resizing electricBills = [90, 95, 70] electricBills(7) = 80

electricBills = 90 95 70 electricBills = 90 95 70 0 0 0 80

Row array resizing: electricBills = [90, 95, 70] electricBills(4) = 60

electricBills = 90 95 70 electricBills = 90 95 70 60

performs an operation on each corresponding pair of elements of two one-dimensional (1D) arrays, yielding a new array. An example of such an element-wise operation is the addition or subtraction of two 1D arrays.

element wise operator

indicates an array with no elements; the array's length is zero. Multiple elements can be deleted in the following manner: Thus if vals = [3, 4, 5, 6], then vals(2) = [] causes vals to become [3, 5, 6].

empty array operator

If the expression evaluates to true, the statements between the if statement and the closing _____ statement will be executed.

end

dailyLog = [9, 4, 6, 3, 4, 5, 2]; firstDay = dailyLog(1) lastDay = dailyLog(7) someDay = dailyLog(8)

firstDay = 9 lastDay = 2 Attempted to access dailyLog(8); index out of bounds because numel(dailyLog)=7.

Iterate with i from 212 to 32 (inclusive).

for i=212:-1:32 % Loop body statements end

statement executes the loop's statement for a fixed number of iterations using an index variable that iterates over a specified set of values. index is stored in the index variable and will iterate over the values from the start index to the end index, inclusive, incrementing the index variable by increment value each iteration.

for loop Ex: for indexVar = startIndex:incrementValue:endIndex % Loop body statements go here end

Use a _______ when the number of iterations is computable before entering the loop, as when counting down from N to 0, printing a character N number times, etc. Use a ________ when the number of iterations is not computable before entering the loop, as when iterating until a user enters a particular character.

for loop While loop

statement supports a single branch and has the form: Ex: if (expression) (Branch taken: Statements to execute when the expression is true) end (Statements here will execute after the above if statement, regardless of whether the branch is taken)

if

Second branch: x is greater than or equal to 100 and less than 200.

if ( x < 100 ) % if statements go here elseif (x<200) % elseif statements go here else % x >= 200 % else statements go here end

num is a non-negative number less than 100

if ((num>=0)&(num<100)) % evaluated to true else % evaluated to false end

num is a 3-digit positive number

if ((num>=100)&(num<=999)) % evaluated to true else % evaluated to false end

Third branch: x is greater than 20 and less than 100.

if (x>=100) % if statements go here elseif ( x <= 20 ) % elseif statements go here else % else statements go here end

num is NOT less than 50, using the < operator

if (~(num<50)) % evaluated to true else % evaluated to false end

statement includes an else part that will execute when the if statement's logical expression evaluates to false.

if-else

Commonly, more than two branches are required, in which case _________ statements can be used having the following form:

if-elseif-else Ex: if (expr1) % Statements to execute when expr1 is true % Execution continues after end elseif (expr2) % Statements to execute when expr1 is false and expr2 is true % Execution continues after end elseif (expr3) % Statements to execute when expr1 and expr2 are false and expr3 is true % Additional elseif statements would go here. else % Statements to execute if all above expressions are false end % Statements here will execute after the above branch statement

Given a row array myArray, a programmer can access an individual element using an integer within parentheses; that integer number is known as an _______

index For example, x = myArray(3) writes the third element of myArray into x, while myArray(1) = 0 writes 0 into the first element of myArray. The indices of a row array with N elements are numbered 1, 2, ..., N.

Returns true if x is finite; otherwise, returns false. For example, isfinite(Inf) is false, and isfinite(10) is true.

isfinite(x)

Returns true if x is +Inf or -Inf; otherwise, returns false.

isinf(x)

Returns true if x is NaN (Not-a-Number); otherwise, returns false.

isnan(x)

Each execution of the loop body

iteration

command creates a row array of linear spaced points, given a start value, stop value, and the number of desired points:

linspace

Use the linspace function to create the same array as 0:0.1:1.

linspace(0,1,11)

Expressions using logical operators are known as _____________. Note that each operand of a logical operator may be a _________, as in (usrAge > 16) & (drunk | drugged), where usrAge is a numerical variable and drunk and drugged are logical variables.

logical expressions

MATLAB offers four ________ for comparing logical variables. When used in the expression for branches and loops (discussed elsewhere) a ____________ treats operands as being true or false, each operates on operands

logical operators

command creates a row array with numOfPoints points, logarithmically spaced from 10^powerStart to 10^powerStop:

logspace logspace(powerStart, powerStop, numPoints)

Often a programmer would like to execute a sequence of statements many times. Most programming languages provide specific constructs called ______ that execute a set of statements between the keywords that delimit the beginning and end of the loop.

loops

is a rectangular array of items in rows and columns.

matrix (also referred to as an array)

Write an expression using a single internal function that returns the same array as [2, 3, 5].^(1/2).

nthroot([2,3,5],2)

numBrs = linspace(1, 5, 5) numsSqrt = sqrt(numBrs)

numBrs = 1 2 3 4 5 numsSqrt = 1.0000 1.4142 1.7321 2.0000 2.2361

Ex: nums = [-5, -99, 82, -105, 102] numsNegLocs = (nums < 0) % Logical array numsNeg = nums(numsNegLocs

nums = -5 -99 82 -105 102 numsNegLocs = 1 1 0 1 0 numsNeg = -5 -99 -105

compares two numerical values and evaluates to a logical value of either true or false.

relational operator

MATLAB offers six _________ for comparing numerical variables. Each operator evaluates to either true or false depending on the operands' values.

relational operators

is a one-dimensional array consisting of 1 row having n columns, each column i containing a single numeric element xi:

row array Ex: [1 2 3]

rowTemps = [-55.39, -44.43, -24.61, -4.83, 15] % For comparison colTemps = [-55.39, -44.43, -24.61, -4.83, 15]' % Transpose

rowTemps = -55.3900 -44.4300 -24.6100 -4.8300 15.0000 colTemps = -55.3900 -44.4300 -24.6100 -4.8300 15.0000

Previously-introduced variables could only store a single item, known as a _________ item

scalar

1. num = colArray(3) 2. vals = colArray(2:4) 3. newArray = colArray * 2 4. rowArray = colArray'

sets num to the third element in colArray creates a column array vals whose elements are the 2nd, 3rd, and 4th elements from colArray multiplies every element in colArray by 2 transposes colArray into a row array.

Use an internal function to compute square roots for [10, 15, 20].

sqrt([10,15,20])

Ex of element wise operator: rowVecA = [1, 4, 5, 2]; rowVecB = [1, 3, 0, 4]; sumEx = rowVecA + rowVecB % Element-wise addition diffEx = rowVecA - rowVecB % Element-wise subtraction dotMul = rowVecA .* rowVecB % Element-wise multiplication dotDiv = rowVecA ./ rowVecB % Element-wise division dotPow = rowVecA .^ rowVecB

sumEx = 2 7 5 6 diffEx = 0 1 5 -2 dotMul = 1 12 0 8 dotDiv = 1.0000 1.3333 Inf 0.5000 dotPow = 1 64 1 16

Sometimes the desired branching of cascaded if-else statements is based on a single-variable with only a few possible values. A ______ statement provides a method to more clearly represent such branching.

switch Ex: switch (expression) case caseExpr1 % statements to execute if expression equals caseExpr1 case caseExpr2 % statements to execute if expression equals caseExpr2 % (and expression does not equal caseExpr1) % Additional case statements should go here. otherwise % statements to execute if no cases match end

temps = [-55.39; -44.43; -24.61; -4.83; 15] sizeTemps = size(temps)

temps = -55.3900 -44.4300 -24.6100 -4.8300 15.0000 sizeTemps = 5

vals = linspace(0, 1, 5)

vals = 0 0.2500 0.5000 0.7500 1.0000

Arrays: The code uses a function ____ that starts an internal timer in MATLAB, and a function ____ that returns the time in seconds since the last call to tic.

tic toc Ex: tic n = 10^5; arryOfSqrs = []; for i = 1:n arryOfSqrs = [arryOfSqrs, i^2]; end toc Command Window: Elapsed time is 19.381420 seconds.

angle = 45; velocity = 34.65; g = 9.8; timeSteps = 0:5 horzPos = velocity * cosd(angle) * timeSteps vertPos = (velocity * sind(angle) * timeSteps) .... - (0.5 * g * (timeSteps.^2))

timeSteps = 0 1 2 3 4 5 horzPos = 0 24.5012 49.0025 73.5037 98.0050 122.5062 vertPos = 0 19.6012 29.4025 29.4037 19.6050 0.0062

Assign totalWeight with the third element of row array carWeights.

totalWeight =carWeights(3);

Another way to construct a column array is to construct and then transpose a row array. The _________________ turns rows into columns. (can also just simply add a ' to the end of the array)

transpose of an array

Write a single-operator expression using a scalar operand that sets all elements of the row array vals = [1, 0, 1, 0] to true.

vals = vals | 1

Iterate until c is equal to the variable n.

while (c~=n) % loop body statements go here end

A __________ executes this list of statements (called the loop body) as long as the loop expression evaluates to true. The loop expression is a logical expression following the while keyword that evaluates to true or false. Logical expressions can include both relational operators (such as < or ==) and logical operators (such as &, |,or ~)

while loop Ex: while (expression) % Statements to execute as long as expression is true end % Statements here will execute after expression is false

Write a statement that concatenates row array newVals to the end of row array xRow. Ex: If newVals is [10, 12] and xRow is [20, 70, 60], then xRow becomes [20, 70, 60, 10, 12].

xRow = [xRow, newVals]

Write a statement that deletes the first two elements from xRow. Ex: [20, 70, 60, 80, 90] becomes [60, 80, 90].

xRow([1, 2]) = []

Ex of empty array operator: xVec = [10:15] sizeOfxVec = size(xVec) xVec(2:4) = [] % Deletes elements 2, 3 and 4 sizeOfxVec = size(xVec)

xVec = 10 11 12 13 14 15 sizeOfxVec = 1 6 xVec = 10 14 15 sizeOfxVec = 1 3


Set pelajaran terkait

LESSON 5:URI NG SULATING AKADEMIKO

View Set

NCLEX A+ Fluid, acid, burn, misc.

View Set

Pol. Science - Political Parties and Elections

View Set

04.08 Segment One Exam Part B U.S. History

View Set