mathlab code
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
Related questions
Question
make mathlab code
![(Matrix-Vector Multiplication) The product of a matrix \( A \) and a (column) vector \( \vec{x} \) is defined provided the number of columns of \( A \) is equal to the number of rows of \( \vec{x} \). Suppose this is the case, and let \( A \) be \( m \times n \) and \( \vec{x} \) be \( n \times 1 \). Then, the product \( A\vec{x} \) is defined element-wise by
\[
(A\vec{x})_j = \sum_{k=1}^{n} A_{j,k}x_k.
\]
For this problem, do not use the built-in ability to multiply matrices and vectors.
**mat_vec Function:**
- **Input variables:**
- a matrix representing \( A \)
- a vector representing \( \vec{x} \)
- **Output variables:**
- a vector representing \( A\vec{x} \); if the sizes do not match, return an empty vector (produced by [] in MATLAB)
A possible sample case is:
```
>> b = mat_vec([1 2 ; 2 1], [2 ; -2])
b =
-2
2
b = mat_vec([1 2 ; 3 4], [5])
b = [](0x0)
```](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F93507587-8486-4bd1-9be9-7c1c5dc70b2a%2Fd667746b-ad56-44d1-87fe-454a32d3ff8f%2Ft9wslbg_processed.png&w=3840&q=75)
Transcribed Image Text:(Matrix-Vector Multiplication) The product of a matrix \( A \) and a (column) vector \( \vec{x} \) is defined provided the number of columns of \( A \) is equal to the number of rows of \( \vec{x} \). Suppose this is the case, and let \( A \) be \( m \times n \) and \( \vec{x} \) be \( n \times 1 \). Then, the product \( A\vec{x} \) is defined element-wise by
\[
(A\vec{x})_j = \sum_{k=1}^{n} A_{j,k}x_k.
\]
For this problem, do not use the built-in ability to multiply matrices and vectors.
**mat_vec Function:**
- **Input variables:**
- a matrix representing \( A \)
- a vector representing \( \vec{x} \)
- **Output variables:**
- a vector representing \( A\vec{x} \); if the sizes do not match, return an empty vector (produced by [] in MATLAB)
A possible sample case is:
```
>> b = mat_vec([1 2 ; 2 1], [2 ; -2])
b =
-2
2
b = mat_vec([1 2 ; 3 4], [5])
b = [](0x0)
```
![(Minimum and Maximum) We often want to find the minimum and maximum values in a vector as well as the indices at which these values occur.
For this problem **do not** use the built-in `min` or `max` function (or any other function which trivializes the problem).
**min_max Function:**
- **Input variables:**
- a vector representing the list of numbers; you may assume each value is unique
- **Output variables:**
- a scalar representing the minimum value
- a scalar representing the index where the minimum value is located in the list
- a scalar representing the maximum value
- a scalar representing the index where the maximum value is located in the list
A possible sample case is:
```
>> [min_val, min_i, max_val, max_i] = min_max(1:5)
min_val = 1
min_i = 1
max_val = 5
max_i = 5
>> [min_val, min_i, max_val, max_i] = min_max([2, 3, 7, 1, 4])
min_val = 1
min_i = 4
max_val = 7
max_i = 3
>> [min_val, min_i, max_val, max_i] = LXX_QYY([1, 2, 3, 4, -1, 0])
min_val = -1
min_i = 5
max_val = 4
max_i = 4
```](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F93507587-8486-4bd1-9be9-7c1c5dc70b2a%2Fd667746b-ad56-44d1-87fe-454a32d3ff8f%2Fgwnld37_processed.png&w=3840&q=75)
Transcribed Image Text:(Minimum and Maximum) We often want to find the minimum and maximum values in a vector as well as the indices at which these values occur.
For this problem **do not** use the built-in `min` or `max` function (or any other function which trivializes the problem).
**min_max Function:**
- **Input variables:**
- a vector representing the list of numbers; you may assume each value is unique
- **Output variables:**
- a scalar representing the minimum value
- a scalar representing the index where the minimum value is located in the list
- a scalar representing the maximum value
- a scalar representing the index where the maximum value is located in the list
A possible sample case is:
```
>> [min_val, min_i, max_val, max_i] = min_max(1:5)
min_val = 1
min_i = 1
max_val = 5
max_i = 5
>> [min_val, min_i, max_val, max_i] = min_max([2, 3, 7, 1, 4])
min_val = 1
min_i = 4
max_val = 7
max_i = 3
>> [min_val, min_i, max_val, max_i] = LXX_QYY([1, 2, 3, 4, -1, 0])
min_val = -1
min_i = 5
max_val = 4
max_i = 4
```
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education