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

3 Ansichten (letzte 30 Tage)
polo Mahmoud
polo Mahmoud am 25 Okt. 2019
Kommentiert: Adam am 25 Okt. 2019
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 Kommentar
Adam
Adam am 25 Okt. 2019
What is the logic behind it? If there is none then you can just hard-code the maths as in Walter's answer.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 25 Okt. 2019
A(2,6:end) = A(2,6:end) + 1;
A(2,end) = A(2,end) + 1; A(3,:) = A(3,:) + 1;

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by