필터 지우기
필터 지우기

Hello, I need a code that gets the local minimum of a histogram by using for loops.

조회 수: 1 (최근 30일)
I did 12 histograms and need to get the local minimums of each of them using for loop.

답변 (1개)

Walter Roberson
Walter Roberson 2022년 5월 23일
Initialize to index 1.
Initialize to "potentially in a local minima"
If you are potentially in a local minima, check to see if the value of the next location is greater than the current value. If it is, then you were in a local minima, and record it, and flip out of potentially mode. But if the value of the next location is equal to the current value, maintain "potentially" mode and continue to the next location. If the value of the next location is less than the current value, make that the new current value and continue in "potentially" mode. If you ran off the end of the array then you were in a local minima.
You should be able to do a similar analysis for the case where you are not currently in "potentially" mode.
  댓글 수: 2
AbdelRahman Mostafa
AbdelRahman Mostafa 2022년 5월 23일
Thank you Walter. Can you write a code for this explanation ?
Walter Roberson
Walter Roberson 2022년 5월 23일
Yes, I could. However, requiring that a for loop is used is an indication of a homework assignment, and you are responsible for writing your own homework.

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

카테고리

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