Effacer les filtres
Effacer les filtres

Hi, I have a matrix ,say A=[1 0 0;0 1 0; 1 0 0] ; I Want to change the value of the first column where I have '1' with 01 & 10 respectively. Is it possible? TIA

2 vues (au cours des 30 derniers jours)
A=[1 0 0;0 1 0; 1 0 0] ;
I Want to change the value of the first column where I have '1' with 01 & 10 respectively. Is it possible?

Réponse acceptée

Walter Roberson
Walter Roberson le 25 Sep 2017
replacements = {[1 0], [0 1]}; %or {'10', '01'}
result = replacements(1+A);
This will give a cell array of values. A cell array is required if you need to preserve the leading '0' of '01': if you were to use
replacements = [10 01];
then
>> replacements(1+A)
ans =
1 10 10
10 1 10
1 10 10

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings 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