Hi,I have numerical matrix 4X4, I have to classify numbers in grades like less than 20, greater than 20 and less than 20, so Hhow can I do it?

3 vues (au cours des 30 derniers jours)
I have numerical matrix 4X4, I have to classify numbers in grades like less than 20, greater than 20 and less than 20, so how can I do it?

Réponse acceptée

Thorsten
Thorsten le 16 Oct 2015
X = randi(30, [4 4])
g20 = X(X > 20)
le20 = X(X <=20)

Plus de réponses (1)

Jack Breenlair
Jack Breenlair le 16 Oct 2015
Modifié(e) : Jack Breenlair le 16 Oct 2015
You want to use two for loops that go through the matrix checking if the numbers satisfy the conditions that you require.
auxiliar=0;
for i=1:4
for j=1:4
if A(i,j)==condition
auxiliar=auxiliar+1;
end
end
end
something like this
  3 commentaires

Connectez-vous pour commenter.

Catégories

En savoir plus sur Statistics and Machine Learning Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by