Extract rows according to the rows sum

1 visualización (últimos 30 días)
shane cannon
shane cannon el 30 de Jul. de 2017
Editada: MSP el 30 de Jul. de 2017
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.

Respuesta aceptada

MSP
MSP el 30 de Jul. de 2017
Editada: MSP el 30 de Jul. de 2017
clear all
close all
A = nchoosek(1:9,3)
x=find(sum(A,2)==15)
B=A(x,:)

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by