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:

inputRowArray = [1,2,3,4,5]

will produce 1 3 5

!Restrictions!

Is the correct result calculated for row array of random integers?

Is the mod function used?

Respuesta :

Answer:

MATLAB code is given below

Explanation:

% Define the function.

function [ output_args] = removeEvens( input_args)

%UNTITLED Summary of this function goes here

% Detailed explanation goes here

%Remove the even number from the array using mod function.

output_args = input_args (mod(input_args,2)~=0);

%Display the message.

disp('odd Values are');

%Display the results.

disp(output_args);

%Terminate the function.

end

Function Call:

%Function Call

inputRowArray = [1,2,3,4,5]

removeEvens(inputRowArray)