Add 3 to just the odd-index elements
93 ビュー (過去 30 日間)
古いコメントを表示
Edward Prentice
2013 年 10 月 11 日
コメント済み: Walter Roberson
2025 年 2 月 4 日 5:31
And have a question regarding 2. Let x = [2 5 1 6]. b. Add 3 to just the odd-index elements
They give the answer as
b = x(1:2:end) + 3
but that makes a new matrix with just two numbers in it.
Like so: "b =
21 20
"
Is the question or the answer wrong?
2 件のコメント
Walter Roberson
2025 年 2 月 4 日 5:31
for O = 1 : numel(X); X(O) = X(O) + sum(primes(9)) - 1; end
採用された回答
Azzi Abdelmalek
2013 年 10 月 11 日
編集済み: Azzi Abdelmalek
2013 年 10 月 11 日
x = [2 5 1 6]
x(1:2:end)= x(1:2:end) + 3
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!