finding the max number?

조회 수: 2 (최근 30일)
Ls
Ls 2021년 9월 12일
답변: Chunru 2021년 9월 12일
x=[1 3 5 7]
y=x^2+5
y=[6 14 30 54]
max(y)
how do i find x value corresponding to max(y)?

답변 (1개)

Chunru
Chunru 2021년 9월 12일
x=[1 3 5 7]
x = 1×4
1 3 5 7
y=x.^2+5 % use .^ here
y = 1×4
6 14 30 54
[~, idx] = max(y) % idx the where y is the max
idx = 4
x(idx) % corresponding x
ans = 7
y(idx)
ans = 54

카테고리

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

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by