Effacer les filtres
Effacer les filtres

how to apply relational operators on matrix elements?

1 vue (au cours des 30 derniers jours)
Dhines
Dhines le 11 Jan 2013
i=[1 2 3 -4;5 -7 8 9;5 6 7 -7;3 4 -2 4]; i want to replace the elements of above matrix with the value greater than 4 by 4, and the matrix elements less than -4 by -4.

Réponse acceptée

James Tursa
James Tursa le 11 Jan 2013
Modifié(e) : James Tursa le 11 Jan 2013
i(i>4) = 4;
i(i<-4) = -4;
or
i = min(max(i,-4),4);
But in the future avoid i as a variable name since that is what MATLAB uses for the imaginary number sqrt(-1).

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB Coder dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by