Problem 1 Write a MATLAB program that will Request the user

Problem 1

Write a MATLAB program that will Request the user for an array. Return another array reporting whether the each of the entries is even or odd. An example of how the input and output should look like:

Solution


% matlab code to take input array and out corresponding even odd array

input_array = input(\"Please enter an array: \")

% determine number of rows and columns
[row,column] = size(input_array)

% iterate over row and column and fill the output array
for i=1:row
   for j=1:column
       if mod(input_array(i,j),2) == 0
           output_array(i,j) = \'Even\'
       else
           output_array(i,j) = \'Odd\'
       end
   end
end

% print the resultant array
disp(output_array);

Problem 1 Write a MATLAB program that will Request the user for an array. Return another array reporting whether the each of the entries is even or odd. An exam

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site