replace value in many colone to one value

i have matrix witn n line row
mtx = [1 1 0 1;
2 0 1 1;
3 1 1 1;
4 1 1 0;
5 1 1 0 ]; % and so on (n rows )
and i want to have this to join value colone 2 and 3 and 4 in one colone
mtx= [1 101;
2 011;
3 111;
4 110;
5 110];

답변 (2개)

Bruno Luong
Bruno Luong 2020년 8월 19일
편집: Bruno Luong 2020년 8월 19일

1 개 추천

Single line
mtx*[1 0; 0 100; 0 10; 0 1]
KSSV
KSSV 2020년 8월 19일
편집: KSSV 2020년 8월 19일

0 개 추천

mtx = [1 1 0 1;
2 0 1 1;
3 1 1 1;
4 1 1 0;
5 1 1 0 ];
[m,n] = size(mtx) ;
iwant = zeros(m,2) ;
iwant(:,1) = mtx(:,1) ;
iwant(:,2) = mtx(:,2:end)*[100 10 1]' ;

댓글 수: 2

alize beemiel
alize beemiel 2020년 8월 19일
wow !
thank You Sir,
thank You very much
KSSV
KSSV 2020년 8월 19일
Thanks is accepting/voting the answer.. :)

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Numeric Types에 대해 자세히 알아보기

태그

질문:

2020년 8월 19일

편집:

2020년 8월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by