No even numbers Write a function removeEvens to remove all the even numbers from
ID: 3588367 • Letter: N
Question
No even numbers Write a function removeEvens to remove all the even numbers from input row array inRowArray which contains integer numbers The function removeEvens should use the mod internal function and operate on a row array of any length. Hint: Use logical indexing and the double square brackets[. Restriction: Do not use loops. For example inputRow Array =[1,2,3,4,5] the function will produce 1 Your Function Save C Reset MATLAB Documentation 1 function [ 1 ] = removeEvens(inROWAr ray) 4 newVal-mod(inRowArray,2) 5 removeEvens=newval (inroWArray) 6 7 end Code to call your function C Reset 1 inputRowArray [1:10] 2 removeEvens( inputRowArray) Run Function OutputExplanation / Answer
'save as removeEvens.m
function [I]=removeEvens(inRowArray)
'The below statement that removes
'even numbers from the vector
'and store result in I vector
I=inRowArray(mod(inRowArray,2)==1)
end
-------------------------------------------------------------------------------------
Run:
--> inputRowArray=[1:5]
inputRowArray =
1 2 3 4 5
--> removeEvens(inputRowArray)
I =
1 3 5
ans =
1 3 5
-->
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.