Write a function called hw3_problem2 that takes an at most two-dimensional matrix A as its sole input. The function returns the largest element of A. You are not allowed to use the built-in max , min, or sort functions.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

How do I do number 2 this is matlab by the way

2 / 2
100% +
Write a function called hw3_problem1 that takes a matrix A of positive integers as its sole input. If the assumption is wrong, the
function returns an empty matrix. Otherwise, the function doubles every odd element of A and returns the resulting matrix. Notice
that the output matrix will have all even elements. For example, the call B = hw3_problem1([1 4; 5 2; 3 1], will make B
equal to [2 4; 10 2; 6 2]. You are not allowed to use loops.
1.
Write a function called hw3_problem2 that takes an at most two-dimensional matrix A as its sole input. The function returns the
largest element of A. You are not allowed to use the built-in max, min,or sort functions.
2.
3. Write a function called hw3_problem3 that takes an at most two-dimensional matrix A as its sole input. The function returns a
row vector v containing all elements of A that are prime numbers. The elements of v are stored according to row-major ordering
of A. You are allowed to use the isprime built-in function.
4. Write a function called hw3 problem4 that takes as input an at most two-dimensional matrix A and computes the sum of the
elements of A that are in the diagonal or are to the right of it. The diagonal is defined as the set of those elements whose column
and row indexes are the same. For example, if the input is [1 2 3; 4 5 6; 7 8 9], then the function would return 26.
Write a function called hw3_problem5 that takes as input an array named X that is a matrix or a vector. The function identifies
those elements of X that are greater than the sum of their two indexes. For example, if the element X(2,3) is 6, then that
element would be identified because 6 is greater than 2+3. The output of the function gives the indexes of such elements found
in row-major order. It is a matrix with exactly two columns. The first column contains the row indexes, while the second column
contains the corresponding column indexes. For example, the call ind
equal to [1 2; 2 1; 3 1]. If no such large element exists, the function returns an empty array.
= hw3_problem5([1 4; 5 2; 6 0]), will make ind
5.
Transcribed Image Text:2 / 2 100% + Write a function called hw3_problem1 that takes a matrix A of positive integers as its sole input. If the assumption is wrong, the function returns an empty matrix. Otherwise, the function doubles every odd element of A and returns the resulting matrix. Notice that the output matrix will have all even elements. For example, the call B = hw3_problem1([1 4; 5 2; 3 1], will make B equal to [2 4; 10 2; 6 2]. You are not allowed to use loops. 1. Write a function called hw3_problem2 that takes an at most two-dimensional matrix A as its sole input. The function returns the largest element of A. You are not allowed to use the built-in max, min,or sort functions. 2. 3. Write a function called hw3_problem3 that takes an at most two-dimensional matrix A as its sole input. The function returns a row vector v containing all elements of A that are prime numbers. The elements of v are stored according to row-major ordering of A. You are allowed to use the isprime built-in function. 4. Write a function called hw3 problem4 that takes as input an at most two-dimensional matrix A and computes the sum of the elements of A that are in the diagonal or are to the right of it. The diagonal is defined as the set of those elements whose column and row indexes are the same. For example, if the input is [1 2 3; 4 5 6; 7 8 9], then the function would return 26. Write a function called hw3_problem5 that takes as input an array named X that is a matrix or a vector. The function identifies those elements of X that are greater than the sum of their two indexes. For example, if the element X(2,3) is 6, then that element would be identified because 6 is greater than 2+3. The output of the function gives the indexes of such elements found in row-major order. It is a matrix with exactly two columns. The first column contains the row indexes, while the second column contains the corresponding column indexes. For example, the call ind equal to [1 2; 2 1; 3 1]. If no such large element exists, the function returns an empty array. = hw3_problem5([1 4; 5 2; 6 0]), will make ind 5.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education