Matlab coding assistance Having some difficulty please help

Matlab coding assistance. Having some difficulty please help! thank you so much in advance!

%% Task 9

% use logical tests to locate and update subsets of a matrix

% Step 1: Create vec, a row vector of 5 random integers on the closed interval [-10,10].

% Step 2: Use a logical mask to count the number of positive values (code provided is already sufficient)

mask = vec > 0

count = sum(mask)

% Step 3: Use the find function to locate where the positive values are in

% the vector (code provided is already sufficient)

inds = find(vec > 0)

% Step 4: Display only the positive values in vec (index into vec using the inds variable)

% Step 5: Negate the positive values by indexing into

% vec using the mask variable, and multiplying all those values by -1

.

%% Task 10

% Matrix multiplication

% Step 1:

%a) Define matrices A, B, and C as shown in Ex 42

% b) compute the expressions 3*A and A+3

% c) compute the expressions A*C, C*A, C*C and C.*C

% comment out any expression that does not compute successfully

% c) compute the expressions A*A and A.*A

% (Be sure you understand the difference between these two operations.

% Step 2:

% a) define matrices A, B and C as shown in Ex 43

% b) compute the matrix operations A*A,B*B and C*C

% comment out any expression that does not compute successfully

% c) use the size function to display the dimensions of B and C

% then compute the matrix operations B*C and C*B

% comment out any expression that does not compute successfully

% (Be sure you understand how to predict which the matrix products will

% compute, along with the dimensions of the result.)

Solution

>>vec=r;

Display only the positive values in vec (index into vec using the inds variable)

len=length(vec);
for inds=1:len;

if vec(inds)>=0

P(inds)=vec(inds);

end

disp(P)

Matlab coding assistance. Having some difficulty please help! thank you so much in advance! %% Task 9 % use logical tests to locate and update subsets of a matr
Matlab coding assistance. Having some difficulty please help! thank you so much in advance! %% Task 9 % use logical tests to locate and update subsets of a matr

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site