How to add a +1 to some of the numbers in a matrix

4 visualizzazioni (ultimi 30 giorni)
Hi
i have a matrix:
A = [1 2 3 4 5 6 7 8 9 10 11 12
7 8 9 10 11 12 13 14 15 16 17 18
13 14 15 16 17 18 19 20 21 22 23 24];
i want:
A = [1 2 3 4 5 6 7 8 9 10 11 12
7 8 9 10 11 12+1 13+1 14+1 15+1 16+1 17+1 18+1
13+1 14+1 15+1 16+1 17+1 18+1 19+1 20+1 21+1 22+1 23+1 24+1];
and then:
A = [1 2 3 4 5 6 7 8 9 10 11 12
7 8 9 10 11 13 14 15 16 17 18 19+1
14+1 15+1 16+1 17+1 18+1 19+1 20+1 21+1 22+1 23+1 24+1 25+1];
my a loop or something ?
  1 Commento
Adam
Adam il 25 Ott 2019
What is the logic behind it? If there is none then you can just hard-code the maths as in Walter's answer.

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 25 Ott 2019
A(2,6:end) = A(2,6:end) + 1;
A(2,end) = A(2,end) + 1; A(3,:) = A(3,:) + 1;

Più risposte (0)

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by