replace value in many colone to one value

1 vue (au cours des 30 derniers jours)
alize beemiel
alize beemiel le 19 Août 2020
Modifié(e) : Bruno Luong le 19 Août 2020
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];

Réponses (2)

Bruno Luong
Bruno Luong le 19 Août 2020
Modifié(e) : Bruno Luong le 19 Août 2020
Single line
mtx*[1 0; 0 100; 0 10; 0 1]

KSSV
KSSV le 19 Août 2020
Modifié(e) : KSSV le 19 Août 2020
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 commentaires
alize beemiel
alize beemiel le 19 Août 2020
wow !
thank You Sir,
thank You very much
KSSV
KSSV le 19 Août 2020
Thanks is accepting/voting the answer.. :)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by