Extract rows according to the rows sum

Hi I have a matrix (A) and I want to extract certain rows that sum to 15. I want to display those rows in another matrix (B). This is my code so far it does not work, please help.
A = nchoosek(1:9,3);
if sum(A,2)==15
disp(B)
end
Thanks.

 採用された回答

MSP
MSP 2017 年 7 月 30 日
編集済み: MSP 2017 年 7 月 30 日

0 投票

clear all
close all
A = nchoosek(1:9,3)
x=find(sum(A,2)==15)
B=A(x,:)

その他の回答 (0 件)

カテゴリ

タグ

質問済み:

2017 年 7 月 30 日

編集済み:

MSP
2017 年 7 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by