Lab 07 Matrices: All Scripts Should Be Stored in Your Firstlastname Folder and Have Clear Names

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Cairo University Faculty of Engineering Credit Hour System GENN004

Lab 07 Matrices
________________________________________________________________________ All scripts should be stored in your FirstLastName folder and have clear names 1. Find an efficient way to generate the following matrix: mat = 7 12 8 10 9 8 10 6

Then, give expressions that will, for the matrix mat, refer to the element in the first row, third column refer to the entire second row refer to the first two columns 2. Write a program to count the even and the odd elements in an array. Assuming the array = [1 7 8 2 4 7], the output should be even=2 and odd=3. . 3. Given an array like [2, 8, 3, 30, 4, 50, 100, 200, 4, 80, 500]. I want to split it into three arrays with different ranges: [0-10), [10-100), and [100-1000). The above array should become 2, 8, 3, 4, 4 30, 50, 80 100, 200, 500 How to do this? 4. Find a short MATLAB expression to build the matrix ( )

a- Write a program that calculates the sum of the elements in each column. So your output will be a 1x3 vector like (14 17 24) b- Write a program that calculates the sum of the elements in each row. So your output will be a 3x1 vector like (6; 21 24) 5. Write a program that reads an array of students grades from the user and creates an array of characters containing the corresponding alphanumeric grades. Use a function to do the conversion.

Lab 07

1/2

Cairo University Faculty of Engineering Credit Hour System GENN004

Example: Enter students grades:[98 23 77 88 99 Alphanumeric grades [A F C B A

65 57] D F]

6. Write a program that reads an array of students grades from the user and creates 1x5 array containing the number of A, B, C, D, and F students. Example: Enter students grades:[98 23 77 88 99 Students statistics A B C D F 2 1 1 1 2

65 57]

Lab 07

2/2

You might also like