Finding t that a max/min occurs at

17 Ansichten (letzte 30 Tage)
Shawna Myatt
Shawna Myatt am 1 Dez. 2018
Kommentiert: Windsor Konkwane am 25 Feb. 2022
I have a f(t) = [600x1] matrix and I need to find the t where the max and the min occur. I know how to find the max and min, but I am not sure how to then find what t these occured at. So if my max is 70, I need to find the t value that gives f(t) = 70. What is the best way to find t? Thanks!

Antworten (2)

Image Analyst
Image Analyst am 1 Dez. 2018
You need to use BOTH min(), max() AND find() to get ALL of the locations:
ft = randi(70, 600, 1); % Sample data
% Step 1: find the max and min values.
maxValue = max(ft)
minValue = min(ft)
% Step 2, find out what rows they occur at.
% NOTE: cannot use the second return value of max() and min() for this
% because it will return ONLY the first occurrence
% of the max or min, not ALL of them
indexesOfMax = find(ft == maxValue)
indexesOfMin = find(ft == minValue)
  2 Kommentare
Shawna Myatt
Shawna Myatt am 2 Dez. 2018
Thank you! between the value code that was given earlier and the find command, I was able to figure it out.
Image Analyst
Image Analyst am 2 Dez. 2018
"Figure it out"? What was left to figure out?
This gave you very explicitly the answer of what indexes the maximum occurred at. Other than possibly renaming my variables, what changes needed to be made?

Melden Sie sich an, um zu kommentieren.


madhan ravi
madhan ravi am 1 Dez. 2018
[value,index]=max(f)
t(index)
[value,index]=min(f)
t(index)
  3 Kommentare
madhan ravi
madhan ravi am 1 Dez. 2018
v(t==100) % to find v when t is 100
value=max(v(t>=1 & t<=10))
value1=min(v(t>=10 & t<=20))
value2=max(v(t>=40 & t<=50))
Shawna Myatt
Shawna Myatt am 2 Dez. 2018
Thanks! Between this and the find command, I was able to figure it out.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by