How to find minimum value ,correspondings to a column ,in an output ?

조회 수: 4 (최근 30일)
Ivan Mich
Ivan Mich 2020년 11월 24일
댓글: Steven Lord 2020년 11월 24일
Hello,
I have a question about a code. My code creates an output .txt file with two columns, (let's say x the 1st column and y the 2nd column) and plot the x-y plot. I am using "min(y)" in order to find the minimum value of y column. I would like to prind on my plot the x value that correspont to the minimum value of y column.
Could you please help me?

채택된 답변

Steven Lord
Steven Lord 2020년 11월 24일
The second output from the min function will help you retrieve the corresponding element of x.
  댓글 수: 2
Ivan Mich
Ivan Mich 2020년 11월 24일
Excuse me but I do not undersatnd you. Which command should I write ?
Steven Lord
Steven Lord 2020년 11월 24일
x = randi(10, 1, 8)
x = 1×8
6 2 9 8 7 4 5 7
y = x.^2
y = 1×8
36 4 81 64 49 16 25 49
[value, loc] = min(y)
value = 4
loc = 2
x(loc)
ans = 2

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by