Question: using matlab, 3 Examining a subarray Write a function vectorQuery(v,n,r) to determine whether the number r appears in the first n components of vector v.

using matlab,

using matlab, 3 Examining a subarray Write a function vectorQuery(v,n,r) to determine

3 Examining a subarray Write a function vectorQuery(v,n,r) to determine whether the number r appears in the first n components of vector v. The function returns 1 if r is in the first n components of v and 0 otherwise. Your function assumes that v is a vector of numbers, n is a positive integer, and r is a number. Use a loop to do the search. (Do not use find or vectorized code.) Make sure that the loop index doesn't go out of bounds" (if n is greater than the length of vector v 4 Creating arrays of unknown lengt Write a function sequence (m) that generates a sequence of random integer numbers between 1 and m, inclusive, stopping when a value is repeated for the first time. The function returns an array containing all the numbers generated (in the order in which they were generated) except for the last value that is a repeated occurrence. Example: If the generated sequence is 3195 72 5, the array to be returned should be 3 19572 Hints: 1) Use the function vectorQuery that you have developed already. 2) When you don't know how long a vector needs to be, you can build it one component at a time. Here is an example to store only the even integer values that a user enters: % Prompt user to enter positive numbers and store the even integers in a vector v 0; % vector length so far num- input ('Enter a positive number: '); while num>0 if rem(num,2)-0 v(k)- num; end num- input ('Enter a positive number (negative to stop): '); end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!