Question: Problem 1: mat = zeros(5,5); for i=1:5 mat(i,i)=55; end a) Write one line describing the function of each line in the above MATLAB code. b)
Problem 1:
mat = zeros(5,5);
for i=1:5
mat(i,i)=55;
end
a) Write one line describing the function of each line in the above MATLAB code.
b) If the table below represents the cells of the array mat, What would be the value of each cell after code execution? ( Fill in the table)
| 1 | 2 | 3 | 4 | 5 | |
| 1 | |||||
| 2 | |||||
| 3 | |||||
| 4 | |||||
| 5 |
Problem 2:
A MATLAB array A has the following values
| 1 | 2 | 3 | |
| 1 | 0 | 3 | 3 |
| 2 | 1 | 3 | 4 |
| 3 | 0 | 4 | 5 |
What would the values of the array be after execution of the following codes (fill in the tables):
a) A(:,1)=0;
| 1 | 2 | 3 | |
| 1 | |||
| 2 | |||
| 3 |
b) 
| 1 | 2 | 3 | |
| 1 | |||
| 2 | |||
| 3 |
A(1,:)- A(1, -A (3,:) (A(1, 2) /A (3,2))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
