Reference no: EM131173661
You have a vector of ones and zeros.
a) Write a function called flipNth, that will flip every Nth entry of the input vector (make the entry 0 if it is 1 and make it 1 if it is 0) and return the modified vector. The function declaration line should be function [outVec] = flipNth(inVec, N)
The first input inVec is a numeric vector of ones and zeros, like V above. The second input is a scalar integer greater than or equal to 1. The output outVec should be a numeric vector of ones and zeros of the same size as inVec.
If the function flipNth is called with only one input argument, then treat the value of N as equal to 1. This is called the default value. Hence the default behavior is to flip every element of the input vector.
b) Write a function called flipNthVal with function declaration line function outVec = flipNthVal(inVec,N,value)
hat will flip every Nth instance of a specified value (0 or 1) in an input vector and return the modified vector.
The input inVec is a numeric vector of ones and zeros. The input N performs the same role as in the previous function flipNth. The input value is which value (0 or 1) to flip. For example, if the function is called with N = 4 and value = 1, the function should flip every 4th occurrence of the value 1. If, on the other hand, the function is called with N = 2 and val = 0, the function should flip every 2nd occurrence of the value 0.
The output outVec should be a numeric vector of ones and zeros of the same size as inVec. If flipNthVal is called with one argument, the default values of N and value are both 1. IfflipNthVal is called with two arguments (inVec abdN), set value to 1.
c) Write a function called findWithOverlap with function declaration linefunction [numAppear, idx] = findWithOverlap(inVec,pattern)
The input inVec is a numeric vector of ones and zeros. The input pattern should be a row vector containing only ones and zeros and whose number of elements is less than or equal to that of inVec. Your function should count how many instances of pattern occur in inVec and return this number to numAppear. Additionally, idx should be a 1-by-numAppear array that contains the starting index for each instance of the pattern. Overlap is allowed.
If pattern has a greater number of elements than inVec, then findWithOverlap should return an empty array. Otherwise the function should return a numeric scalar.
Identify activity in doctors office that fall into move time
: Identify the activities in the doctor's office that fall into process time, inspection time, move time, wait time, and storage time.
|
Relationship between the companys values and strategy
: What is the relationship between SWOT and Strategy? Provide real world examples. Additional research is necessary by using scholarly publications. Cite accordingly.
|
Calculate the vibration amplitude and its uncertainty
: The vibrating wedge shown in Fig. 11.1 is used for an amplitude measurement. The length of the wedge is 15 cm ± 0.5 mm and the thickness is 2.5 cm ± 0.2 mm. The x distance is measured as x = 5.6 cm ± 1.3 mm. Calculate the vibration amplitude and i..
|
Allocates control efforts accordingly
: The A-B-C approach classifies inventory items according to some measure of importance, usually annual dollar value- and then allocates control efforts accordingly.
|
Vector of ones and zeros
: Write a function called flipNth, that will flip every Nth entry of the input vector (make the entry 0 if it is 1 and make it 1 if it is 0) and return the modified vector. The function declaration line should be function [outVec] = flipNth(inVec, N)
|
Explain the role of managerial accounting
: Describe the role of managerial accounting and the management accountant in a business or organization. Describes ethical issues/concerns for the management accountant
|
Probability that the first card is a spade
: A card is randomly chosen from the deck. It is then replaced and a second card is chosen. What is the probability that the first card is a spade and second card is a diamond?
|
Greater percentage of republican
: What is the probability that the survey will show a greater percentage of Republican voters in the second state than in the first state?
|
Find the probability that an even number
: Question 1: A die is rolled, find the probability that an even number is obtained. Question 2: Two coins are tossed, find the probability that two heads are obtained.
|