How to replace value if it is multiple of other Value

2 vues (au cours des 30 derniers jours)
Med Future
Med Future le 16 Déc 2022
Réponse apportée : KSSV le 16 Déc 2022
Hello, I have the following value
Maximumvalue=45
Minimumvalue=15
I want apply a if else condition if the Maximumvalue if multiple of Minimumvalue then Maximumvalue should be replace with Minimum Value,
How can i do it in matlab

Réponse acceptée

KSSV
KSSV le 16 Déc 2022
A = [3 4 5 9]
A = 1×4
3 4 5 9
[A0,idx0] = min(A) ;
[A1,idx1] = max(A) ;
if ~mod(A1,A0)
A(idx1) = A0 ;
end
A
A = 1×4
3 4 5 3

Plus de réponses (0)

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by