필터 지우기
필터 지우기

Match function in matlab

조회 수: 18 (최근 30일)
Mateusz Brzezinski
Mateusz Brzezinski 2020년 2월 20일
답변: Melissa Rosa 2023년 3월 1일
Hello,
I am looking for a function that corresponds to the excel "match" function.
I have an array of (n,32) where n is sated in for loop function as a number of completed loops (so it differs).
DataOutput = zeros(length(phiAStart:phiAStep:phiAEnd),32);
I would like to find the smallest value in column 32 (y) and get the corresponding value in column 1 (x) where y=f(x).
DataOutput(colector,1) = x;
DataOutput(colector,32) = y;
I can not resolve a function (to get x) having y because it's numerically calculated polynomial so I thought about something similar that MATCH function from excel.
Is there any similar function in Matlab or simple script that can be introduced?
I will be thankful for any suggestions or codes that may work.

채택된 답변

Mateusz Brzezinski
Mateusz Brzezinski 2020년 2월 20일
편집: Mateusz Brzezinski 2020년 2월 20일
number = min(DataOutput(:,32));
position = find(DataOutput(:,32)==number);
matchingx = DataOutput(position,1)
Works just fine
  댓글 수: 2
Steven Lord
Steven Lord 2020년 2월 20일
That will give you all the matching x values. Do you want that or do you want the first such match?
Mateusz Brzezinski
Mateusz Brzezinski 2020년 2월 21일
편집: Mateusz Brzezinski 2020년 2월 21일
Ok, so what I have is 3rd derivative (f''') from fuction (f)
f''' always has only one root. I just assigned absf'''=abs(f''') to (DataOutput(colector,32)) so it flips negative values of f''' and I am looking for smalest value of absf''' and code above returnes me only one abs(f''') value.

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

추가 답변 (2개)

Steven Lord
Steven Lord 2020년 2월 20일
Call the min function with two outputs. Use the second output to retrieve the corresponding value.
  댓글 수: 1
Mateusz Brzezinski
Mateusz Brzezinski 2020년 2월 20일
Ok, thanks but how should it be done?

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


Melissa Rosa
Melissa Rosa 2023년 3월 1일
2x+4y

카테고리

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

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by