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
icon
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)
```
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
```
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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
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