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

4 ビュー (過去 30 日間)
polo Mahmoud
polo Mahmoud 2019 年 10 月 25 日
コメント済み: Adam 2019 年 10 月 25 日
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 件のコメント
Adam
Adam 2019 年 10 月 25 日
What is the logic behind it? If there is none then you can just hard-code the maths as in Walter's answer.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2019 年 10 月 25 日
A(2,6:end) = A(2,6:end) + 1;
A(2,end) = A(2,end) + 1; A(3,:) = A(3,:) + 1;

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by