Matrix B from column of matrix A with condition

3 vues (au cours des 30 derniers jours)
Uros Markovic
Uros Markovic le 13 Juin 2021
Commenté : RITURAJ le 27 Août 2023
Hello,
I have to create matix B that contains columns of matrix A which product of elements are greater than 20. How can i code this? Thanks.

Réponse acceptée

Mouhamed Niasse
Mouhamed Niasse le 13 Juin 2021
Modifié(e) : Mouhamed Niasse le 13 Juin 2021
Hello,
Here is what i achieved. Hope you can easily understand it.
A=randi(5,5) % Just for an example, A is a 5x5 array of random integers
B=A(:,prod(A)>20) % This is the only line you'll need for any given matrix A.
  1 commentaire
RITURAJ
RITURAJ le 27 Août 2023
I think it is "Rand" and not "Randi"

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by