필터 지우기
필터 지우기

Extract rows according to the rows sum

조회 수: 3 (최근 30일)
shane cannon
shane cannon 2017년 7월 30일
편집: MSP 2017년 7월 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