Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 4. [15 Marks] Write a MATLAB program that receives a matrix with positive integer numbers from a user (we assume the user just enters
Question 4. [15 Marks] Write a MATLAB program that receives a matrix with positive integer numbers from a user (we assume the user just enters positive integer numbers, so no need to further check) and then calculates and outputs the factorial of summation of even numbers (existing in the matrix) in a form of a formatted message as follows: The factorial of summation of even elements in the given matrix is xx. Your code should consider situations that there is no even element or just one even element in the matrix. In these cases, the MATLAB code should output one of the corresponding messages indicated below: There is no even element in this matrix. There is only one even element in this matrix and its factorial is xx. You should write your code in a systematic programming form. Hint: For example, if the matrix entered is A= [2 1;3 2] the factorial of summation of even elements is 24. Note: Your solution should be comprehensive and can be used for any matrix dimension. You should not use MATLAB built-in function factoriall for this question. Also, you should implement the factorial calculation within the same script not in a separate function file
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started