Question: Matlab code assistance. Please help! % housekeeping clc % clear command window (console) clearvars % clear workspace %% Task 1 % create the 3 row

Matlab code assistance. Please help!

% housekeeping

clc % clear command window (console)

clearvars % clear workspace

%% Task 1

% create the 3 row vectors shown in Ex 8 using 3 different approaches

% 1. list the values explicitly (square brackets)

% 2. use the colon operator

% 3. use the linspace function

%% Task 2

% create a row vector with a randomly-generated upper bound

% Step 1 generate a random integer on the closed interval [10,25]

myend =

% Step 2: use the colon operator to create vec, a row vector of the integers ranging from

% 1 to myend, incrementing (step value) by 3

vec =

% Step 3: write the assignment statement that transposes vec into a column vector

%% Task 3

% Step 1: Assign v1, a row vector of any 5 values.

v1 =

% Step 2: Assign v2, a row vector of any 6 values.

v2 =

% Step 3:

% For each vector, write the expression that selects only the elements

% in the odd-numbered positions (i.e., the first, third, etc.,value listed in the vector).

% When indexing into each vector, use the "end" keyword and NOT the number of elements.

% Step 4:

% For each vector, write the expression that selects only the elements

% in the even-numbered positions (i.e., the second, fourth, etc.,value listed in the vector).

% When indexing into each vector, use the "end" keyword and NOT the number of elements.

%% Task 4

% Step 1: Create r1, a row vector of the odd values from 1 to 100.

% Do not explicitly list all the values! Use the colon operator and a step value.

% Step 2: Create r2, a row vector of 50 evenly-spaced values ranging

% from -3 to 30, inclusive. Do not explicitly list all the values!

% Step 3: Create mat, the matrix whose first row is r1, and whose

% second row is r2.

% To stack the row vectors, use the semi-colon inside the square brackets

% Step 4: Using two indices, write the expression for the mat value located at row 1, col 3

% Step 5: Assign a new variable c3, a col vector containing all values in mat col 3.

% Step 6: Assign a new variable c39, that contains all values in mat cols 3 through 9 (inclusive)

% Step 7: Assign a new variable c3_9, that contains all values in

% mat columns 3 and 9 only.

%% Task 5

% Step 1: Create three random variables, each of which is a 2x3 matrix

% a) random values should be real numbers on open interval (0,1)

% b) random values should be real numbers on open interval (0,10)

% c) random values should be integers on closed interval [5,20]

% Step 2: Using max, write an expression to find the maximum values in your matrix from Step 1c

% a) largest value in each column (should produce a row vector)

% b) largest value in each row (should produce a col vector)

% c) large value overall (should produce a scalar)

% Step 3: update your matrix from Step 1c.

% The updated version should be a 2x2 matrix, containing the values from cols 1 and 3 only

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 Databases Questions!