Extract rows according to the rows sum

1 次查看(过去 30 天)
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
clear all
close all
A = nchoosek(1:9,3)
x=find(sum(A,2)==15)
B=A(x,:)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by