how can ı find min value using for loop in matrice

조회 수: 17 (최근 30일)
sarp karayegen
sarp karayegen 2020년 4월 23일
댓글: vinita 2022년 10월 29일
[1:100] matrice

답변 (2개)

Deepak Gupta
Deepak Gupta 2020년 4월 23일
편집: Deepak Gupta 2020년 4월 23일
You really don't need to use for loop in matlab to find min term.
If you have a matrix A, then min(A) will give you minimum value in matrix.
  댓글 수: 1
Deepak Gupta
Deepak Gupta 2020년 4월 23일
If you really need for loop then:
minTerm = A(1, 1);
for i= 1:size(A, 1)
for j = 1:size(A, 2)
if(A(i, j)<minTerm)
minTerm = A(i, j);
end
end
end

댓글을 달려면 로그인하십시오.


Prasad Reddy
Prasad Reddy 2020년 4월 23일
clc
clear all
A=[2,4,5,7,4,3,5,6] % creating our required vector
l=length(A) % finding the length of our vector
min=A(1); % assain the first value of our vector to min
for i=1:1:l
if A(i)<min % from then onwards check each element and
min=A(i) % if the element is less than the value stored in min
end % assain new value
end
min
  댓글 수: 1
vinita
vinita 2022년 10월 29일
thank u. but if i have 64x64 matrics then how we calculate the minmum value using loop.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by