Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Directions First, use Matlab to create another folder inside your projects folde

ID: 2079702 • Letter: D

Question

Directions First, use Matlab to create another folder inside your projects folder called laatname initial-pp01 where laatname is YOUR last name and initial is YOUR first initial. Use all lower-case letters when naming your folder for this assignment. Second, download the grading script for this problem and save it to the folder you just created. Make sure you save all the .m-files for this assignment to this folder as well. When you have finished the assignment, run the grading script and then use Matlab to create a zip file of your assignment folder. This folder must contain all your m-files and the results of the grading script. Submit only this .zip file to the D2L dropbox. Problems 1. Create a Matlab function called rejects.n which acts in the following way: given two inputs, a vector of positive int called nums and a positiveinteger called specval, the function returns a new vector called losers containing all the elements of nums which are not exactly divisible by apecval e. when divided by specval will have non-zero remainder). Function specifications and some sample function calls are shown below. input parameters numas a vector of positive integers apecval a positive integer output parameter losers a vector containing the elements of nums which are evenly divisible by apecval sample function calls rejects [2,3,4,5,6,7,8] 4) produces the vector C2,3,5,6,7] rejects [3,7,2,8,6,9], 3) produces the vector C7.2,8) rejects 5,7,9] ,2) produces the vector [1.3,5.7,9]

Explanation / Answer

Solution to problem 1:

Matlab Code:

function losers = rejects(nums,specval)

n=length(nums);
count=0;

for i=1:n
r=mod(nums(i),specval);
if(r~=0)
count=count+1;
losers(count)=nums(i);
end
end
  

Now the various realisations of this code with the given sample function calls:

rejects([2,3,4,5,6,7,8],4)

ans =

2 3 5 6 7

>> rejects([3,8,6,7,2,9],3)

ans =

8 7 2

>> rejects([1,3,5,7,9],2)

ans =

1 3 5 7 9

>>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote