Write a script named YourLastNameA6_HW_1.m Pattern Finding Problem Given a vector of arbitrary length consisting of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a script named "YourLastNameA6_HW_1.m" Pattern Finding Problem Given a vector of arbitrary length consisting of ones and zeros, and a pattern such as [1 0 1 0], your goal is to determine if the pattern occurs in the vector and the starting index of its location. 1. Write a local function GenVector that takes as its input argument the length of the vector and returns a random vector of that length consisting of random Os and 1s. Name this random vector rVec. 2. Write a local function ContainsMatch that takes two input arguments, the random vector rVec and the pattern to test testPatt. The function should return either false (logical 0) if the pattern is not found, or the index of the starting position of the first occurrence of the test pattern in the test vector. For example, suppose rVec = [101011] and testPatt = [1 1] your function should return: 5, since [11] starts at index position 5. 3. You should test with special cases (are the inputs Os and 1s? is the length of testPatt less than or equal to the length of rVec? Anything else you can think of?) 4. Clearly document your code. Make your sample vector length equal to 100. Some sample patterns to test: testPat1 = [1] testPat2 = [1010] test Pat3 = [0 0 0 0] test Pat4 = [00001111] i. ii. iv. Write a script named "YourLastNameA6_HW_1.m" Pattern Finding Problem Given a vector of arbitrary length consisting of ones and zeros, and a pattern such as [1 0 1 0], your goal is to determine if the pattern occurs in the vector and the starting index of its location. 1. Write a local function GenVector that takes as its input argument the length of the vector and returns a random vector of that length consisting of random Os and 1s. Name this random vector rVec. 2. Write a local function ContainsMatch that takes two input arguments, the random vector rVec and the pattern to test testPatt. The function should return either false (logical 0) if the pattern is not found, or the index of the starting position of the first occurrence of the test pattern in the test vector. For example, suppose rVec = [101011] and testPatt = [1 1] your function should return: 5, since [11] starts at index position 5. 3. You should test with special cases (are the inputs Os and 1s? is the length of testPatt less than or equal to the length of rVec? Anything else you can think of?) 4. Clearly document your code. Make your sample vector length equal to 100. Some sample patterns to test: testPat1 = [1] testPat2 = [1010] test Pat3 = [0 0 0 0] test Pat4 = [00001111] i. ii. iv.
Expert Answer:
Answer rating: 100% (QA)
Solution YourLastNameA6HW1m Local function GenVector generates a random vector of ones and zeros ... View the full answer
Related Book For
Fundamentals Of Digital Logic With Verilog Design
ISBN: 9780073380544
3rd Edition
Authors: Stephen Brown, Zvonko Vranesic
Posted Date:
Students also viewed these programming questions
-
Learners will evaluate a system with object-oriented design and coupling violations. Learners will gain hands-on experience with improving the software system's quality and modifiability by...
-
You have completed your first meeting with Harper and Riley Evans. You are confident that you now have most of the information you will need to prepare a comprehensive financial plan for them. Beyond...
-
Zolezzi Incorporated is preparing its cash budget for March. The budgeted beginning cash balance is $29,000, Budgeted cash receipts total $100,000 and budgeted cash disbursements total $91,000. The...
-
A small container of water is placed on a carousel inside a microwave oven, at a radius of 12.0 cm from the center. The turntable rotates steadily, turning through one revolution in each 7.25 s. What...
-
Westerville Company reported the following results from last year's operations: Sales . . . . . . . . . . . . . . . . . . . . . . $1,000,000 Variable expenses . . . . . . . . . . . . . 300,000...
-
A 6-ft-long steam pipe is made of A-36 steel with y = 40 ksi. It is connected directly to two turbines A and B as shown. The pipe has an outer diameter of 4 in. and a wall thickness of 0.25 in. The...
-
McLaren Corporation has net income of $11.44 million and net revenue of $80 million in 2010. Its assets are $14 million at the beginning of the year and $18 million at the end of the year. What are...
-
2. a) Illustrate how BUILD-MAX-HEAP (A) works on the array A = {2, 9, 6, 8, 11, 4, 5, 3, 1, 7}. Each step is the result of one call to the MAX-HEAPIFY function. Show both the array view and the tree...
-
Forecasting with the Parsimonious Method and Estimating Share Value Using the ROPI Model Following are income statements and balance sheets for Cisco Systems. Cisco Systems Consolidated Statements of...
-
Let A, B,C be a partition of t, that is, - AUBUC and A, B, C are disjoint. Give the smallest o-algebra F generated by {A, B, C). Answer. F= {0, 0, A, B, C, AUB, AUC, BUC). Explain. 3 4* Let A and B...
-
A company is thinking about outsourcing its call centre operations. The total cost of making this move is $500,000 and the total benefits are $400,000. However, the incremental costs and benefits are...
-
Question 3: (10 Points): For the bend shown in figure below, if the flow rate= 0.05 m/s, and the pressure at section 2 = 100 kPa. The difference in elevation between sections 1 and 2 = 10 m,...
-
Sirlin Co., a CCPC that is not associated with any other corporation, had taxable income in the current year of $700,000, consisting of ABI of $600,000 and AII of $100,000. Sirlin also received total...
-
Naeha has attained two years of service with her employer, Fiasco, Inc. (FI). FI sponsors a top-heavy qualified profit-sharing plan and Naeha's vested account balance within the plan is $40,000. If...
-
Given the registry of the premiums of an insurance. company for years 2005, 2006, 2007 and 2008. Cover Period Issue Date of the Receipt 1.2.05 1.5.05 1.8.05 1.2.06 1.4.06 1.10.06 1.1.07 1.3.07...
-
Establish first that y(t) = aet + bet+c cosh(t) + d sinh(t) solves the differential equation, dy dt (t)- y(t) = 0. This solution contains four different homogeneous solutions when we know that we...
-
Provide a few individual examples who revealed what aspects of emotional intelligence?
-
Design a three-bit counterlike circuit controlled by the input w. If w = 1, then the counter adds 2 to its contents, wrapping around if the count reaches 8 or 9. Thus if the present state is 8 or 9,...
-
Consider the circuit in Figure P3.1. Can this circuit be used as one stage in a ripple-carry adder? Discuss the pros and cons. The operation of transistors shown in the figure is described in...
-
Sensitize each path in the combinational part of the circuit in Figure 11.12 to obtain a complete test set that comprises as few tests as possible. Show how your test set can be applied to test this...
-
Use the code given earlier for R to make this plot. The command would be plot(percentage)
-
Why would you not feel comfortable computing a Pearson correlation on the data in Exercise 9.10? Exercise 9.10 Down syndrome is another problem that psychologists deal with. It has been proposed that...
-
In Exercise 9.1 the percentage of mothers over 40 does not appear to be important, and yet it is a risk factor in other societies. Why do you think that this might be? Exercise 9.1 In Sub-Saharan...
Study smarter with the SolutionInn App