## How to loop this operation ?

Asked by Andrea Di Lelio

### Andrea Di Lelio (view profile)

on 12 Sep 2019
Latest activity Answered by Andrei Bobrov

### Andrei Bobrov (view profile)

on 12 Sep 2019
Accepted Answer by Andrei Bobrov

### Andrei Bobrov (view profile)

Hello everybody,
I am trying to think about a loop in order to produce with 4/5 rows of code a simple result.
I have one vector of dimension 300x1 (called TarG) and the next ones are the operation that I would like to loop.
D_11 = TarG(300) / 100;
D_12 = (TarG(280) / TarG(281)) * D_11;
D_13 = (TarG(260) / TarG(261)) * D_12;
D_14 = (TarG(240) / TarG(241)) * D_13;
D_15 = (TarG(220) / TarG(221)) * D_14;
D_16 = (TarG(200) / TarG(201)) * D_15;
D_17 = (TarG(180) / TarG(181)) * D_16;
D_18 = (TarG(160) / TarG(161)) * D_17;
D_19 = (TarG(140) / TarG(141)) * D_18;
D_20 = (TarG(120) / TarG(121)) * D_19;
D_21 = (TarG(100) / TarG(101)) * D_20;
D_22 = (TarG(80) / TarG(81)) * D_21;
D_23 = (TarG(60) / TarG(61)) * D_22;
D_24 = (TarG(40) / TarG(41)) * D_23;
D_25 = (TarG(20) / TarG(21)) * D_24;
Tot_TarG = [D_11; D_12; D_13; D_14; D_15; D_16; D_17; D_18; D_19; D_20; D_21; D_22; D_23; D_24; D_25];
Is there someone that could help me?

Stephen Cobeldick

### Stephen Cobeldick (view profile)

on 12 Sep 2019
What sizes are the very unfortunately named D_11, D_12, etc.?
Using numbered variables is s sign that you are doing something wrong. You should read this:
Andrea Di Lelio

### Andrea Di Lelio (view profile)

on 12 Sep 2019
Each bad name is a single value. Those are just names now that I used to explain faster.

### Andrei Bobrov (view profile)

Answer by Andrei Bobrov

on 12 Sep 2019