MATLAB Write the proper \'display header\' for each part. Give a short comment i
ID: 3112024 • Letter: M
Question
MATLAB
Write the proper 'display header' for each part. Give a short comment in front of each line as needed.
Final_value= 30, row_vec1=[20:8:30], row_vec2 = linspace(2, 56, 2), matrix1 = [row_vec2; row_vec1]
(1e)-Append matrix1 to the bottom of row_vec1 vector and call it matrix2. Change the value of the final_value to a new value (to the smallest number possible) that your output becomes a 3x4 matrix and assign this matrix to a variable calls matrix3
(1f)-swap column 4 of matrix2 with column 1. This is your final output.
(1g)-Compare matrix2 and matrix3 by generating a Boolean matrix to see which elements are equal. (1 if equal and 0 if they are not)
Explanation / Answer
%% Matlac code
% % given parameter
final=30;
row_vec1=[20:8:30];
row_vec2=linspace(2,56,2);
matrix1=[row_vec2;row_vec1];
% % Task-1
matrix2= [row_vec1; matrix1];
% % Task-2
% % changing value of final=50
final=55;
row_vec1=[20:8:50];
row_vec2=linspace(2,56,4);
matrix1=[row_vec2;row_vec1];
matrix2= [row_vec1; matrix1];
% % Task-3
matrix3=matrix2;
% % % Swaping column4 with column1
matrix2=[matrix3(:,4) matrix3(:,2) matrix3(:,3) matrix3(:,1)];
% % Comparing matrix
c= matrix2==matrix3;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.