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

Harshal
Harshal 2025년 2월 4일
ADD 16 TO EACH ELEMENTS OF X
for O = 1 : numel(X); X(O) = X(O) + sum(primes(9)) - 1; end

댓글을 달려면 로그인하십시오.

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 10월 11일
편집: Azzi Abdelmalek 2013년 10월 11일

9 개 추천

x = [2 5 1 6]
x(1:2:end)= x(1:2:end) + 3

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by