Effacer les filtres
Effacer les filtres

how to compare each element of matrix?

1 vue (au cours des 30 derniers jours)
Dhines
Dhines le 10 Jan 2013
here...i taken some variable as t ,value is 4(t=4),and f is a 4x4 matrix.. f=[1 2 3 4; 2 3 4 5 ; 5 6 7 8 ; 1 2 3 5].. how to compare the each element of matrix with T?

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 10 Jan 2013
Modifié(e) : Andrei Bobrov le 10 Jan 2013
t = 4;
f = [1 2 3 4; 2 3 4 5 ; 5 6 7 8 ; 1 2 3 5];
out = abs(f - t) < eps(100)
ADD
out = f;
out(f <= t) = -4;
  6 commentaires
Dhines
Dhines le 10 Jan 2013
thank u sir..little bit doubt there in ur add part...when i get output form of fh the lowest value as represent -4 thats ok. but the greater value want to present as '4' ,there is print as only matrix value..please correct that one .
Andrei Bobrov
Andrei Bobrov le 10 Jan 2013
Modifié(e) : Andrei Bobrov le 10 Jan 2013
out = t*((f > t)*2-1)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by