finding the max number?

6 vues (au cours des 30 derniers jours)
Ls
Ls le 12 Sep 2021
Réponse apportée : Chunru le 12 Sep 2021
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)?

Réponses (1)

Chunru
Chunru le 12 Sep 2021
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

Catégories

En savoir plus sur Structures dans Help Center et File Exchange

Tags

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by