Use Matlab and attach all Matlab codes to solve (Coding Practice) Write a MATLAB
ID: 3683300 • Letter: U
Question
Use Matlab and attach all Matlab codes to solve
(Coding Practice) Write a MATLAB function that takes a matrix A as input,
and nds the minimum element from this matrix and its corresponding row index
and column index. The function header is:
function [minele, row, col]= ndminele(A)
where the input A is a matrix, and the output minele is the minimum element in
A, and the outputs row and col are the corresponding row and column indices of
minele. (Note: you are NOT allowed to use the built-in MATLAB function min
here.)
Explanation / Answer
Code:
function [minele, row, col]= findminele(A)
[m,n]=size(A);
minele=A(1,1);
row=1;
col=1;
for i=1:m
for j=1:n
if (minele>A(i,j)):
minele=A(i,j);
row=i;
col=j;
end
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.