Question: section 1 : array basics 1 ) initialize and access array elements ( 5 points ) - Define a 1 d array ( row vector

section 1: array basics
1) initialize and access array elements (5 points)
- Define a 1d array (row vector) A with values from 1 to 10
- access and display the 3rd,5th, and last element in the array.
2) array modification (5 points)
- change the value of the 5th element in A to 20.
- display the modified array
section 2: array operations
1) elementwise operations (10 points)
- create a 1d array (column vector) B with values 2 to 20 in increments of 2
- compute the sum of the transpose of A and B and store it in a new array C
- compute the elementwise product of transpose of array A and B and store it in D
- display arrays C and D.
2) logical operations (10 points)
- Create a 1d array (row vector) of length 10 E with the integer values:
9981478205
- use a logical condition to identify the elements in E that are greater
than 5 and store the result in an array named greater_than_5
- count how many elements meet this condition and store the result in n_elements
- display the result n_elements
section 3: 2D arrays (matrices)
1) matrix initialization and access (10 points)
- define a 3x3 matrix F with values from 1 to 9(123 in the top row, 4
67 in the second row and 789 in the third row)
- access and display the element in the second row, third column
- Change the element in the third row, first column to 10 and display the updated matrix.
2) matrix operations (10 points)
- define another 3x3 matrix G with values [9,8,7; 6,5,4; 3,2,1].
- calculate the matrix sum of F and G and store it in sum_matrix
- calculate the product (elementwise) of F and G and store it in
prod_matrix
- display the resulting matrices (sum_matrix and prod_matrix)
Section 4: array slicing and concatenation
1) array slicing (5 points)
- define a 1d array H with values from 1 to 100
- create a new array H_subset that extracts every 5th element from H
- display H_subset
2) array concatenation (10 points)
- define two 1d arrays (row vectors) I1 with values from 1 to 5, and I2 with values from 6 to 10
- concatenate I1 and I2 along rows (horizontally) to form a new array I_combined_h
- concatenate I1 and I2(vertically) to form a new 2d array I_combined_v
- display the horizontally concatenated array I_combined_h
- display the vertically concatenated array I_combined_v
section 5: comprehensive task
1) temperature conversion (10 points)
- create an array temps_c with temperatures in degrees celsius [0,20,35,40,60,100].
- convert each element in temps_c to fahrenheit and store the results in an array temps_f
note: conversion from celsius to fahrenheit: Fahrenheit =
Celsius*9/5+32
- Display both arrays side by side in a two-column format (hint, vector
concatenation)
2) array manipulation (10 points)
- define a 2d array J as reshape(1:20,[4,5]).
- manually flip the matrix J horizontally by reordering the columns and
store the result in J_flip
column n should become column 1
column n-1 should become column 2
- transpose the manually flipped matrix
- display the matrices J, J_flip and J_final
MATLAB Code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!