I want to add number in given sequention

1 view (last 30 days)
I want to add 0.5 to x2, x5, x8, x11 and so on, without altering the value of x1, x3, x4, x6, x7, x9, x10. How to write code for such problem.
Thank you
0.709416 x1
0.709416 x2
0.709416 x3
0.707508 x4
0.707508 x5
0.707508 x6
0.705603 x7
0.705603 x8
0.705603 x9
0.703701 x10
0.703701 x11

Accepted Answer

Voss
Voss on 8 Dec 2021
Referring to the code you posted in a comment:
v(2:3:end) = v(2:3:end)+0.05;

More Answers (1)

KSSV
KSSV on 8 Dec 2021
You can extract indices using:
idx = 2:2:11 ;
  2 Comments
Rik
Rik on 8 Dec 2021
I'm a bit confused about what you actually want to do. It sounds like KSSV's suggestion is exactly what you need:
v(2:2:end)=v(2:2:end)+0.5;

Sign in to comment.

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!