Lab Assignment 1 Aim
Lab Assignment 1 Aim
% Fill the matrix with values ranging from 0 to 255 in blocks of 4 rows
for i = 0:255
startRow = i * 4 + 1;
endRow = (i + 1) * 4;
matrix(startRow:endRow, :) = i;
end
% Display the entire matrix
disp(matrix);
%% column wise
% Fill the matrix with values ranging from 0 to 255 in blocks of 4 columns
for i = 0:255
startCol = i * 4 + 1;
endCol = (i + 1) * 4;
matrix(:, startCol:endCol) = i;
end
%% diagonal wise
% Fill the matrix with values ranging from 0 to 255 in blocks of 4 rows
for i = 0:255
startRow = i * 4 + 1;
endRow = (i + 1) * 4;
matrix(startRow:endRow, :) = i;
end
% Column-wise
matrixCol(:, i*4 + 1:(i+1)*4) = i;
% Diagonal-wise
matrixDiag(i*4 + 1:(i+1)*4, i*4 + 1:(i+1)*4) = i;
end
Observations:
Each filling pattern results in a structured matrix arrangement:
Row-wise: Blocks of 4 rows with increasing values from 0 to 255.
Column-wise: Blocks of 4 columns with increasing values from 0 to
255.
Diagonal-wise: Diagonal blocks of 4x4 with increasing values from 0
to 255.
The row-wise and column-wise patterns exhibit clear row and column
structures, respectively, whereas the diagonal-wise pattern forms
diagonal structures across the matrix.
Conclusion:
In conclusion, by examining these different matrix filling patterns
within a single experiment, we gain insights into their respective
characteristics, functionalities, and potential applications,
empowering informed decision-making in computational tasks and
algorithm design. Understanding these patterns enables the selection
of the most suitable arrangement for specific computational tasks,
optimizing performance and resource utilization