Matrix B from column of matrix A with condition

조회 수: 1 (최근 30일)
Uros Markovic
Uros Markovic 2021년 6월 13일
댓글: RITURAJ 2023년 8월 27일
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.

채택된 답변

Mouhamed Niasse
Mouhamed Niasse 2021년 6월 13일
편집: Mouhamed Niasse 2021년 6월 13일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by