## How do I create a loop that doubles the number of points in a random data set, starting at 50 and going to 51,200 in factors of 2?

### Conor (view profile)

on 5 Feb 2013

Need to create a loop that doubles the number of points in a random data set, starting at 50 and going to 51,200 in factors of 2.

So far Ive got this, which doesnt seem to work, as it gives me a 1x51200 matrix of randomly generated numbers:

```for i=1:1024,
randn(1,50.*i)
end
```

Would appreciate any help.

Thanks!

bym

### bym (view profile)

on 5 Feb 2013

Not sure what you mean -- does the initial data set vary between 50 and 51200 elements and you want to double the number of elements?

Azzi Abdelmalek

### Azzi Abdelmalek (view profile)

on 5 Feb 2013

Why are using a for loop, if you are not storing your calculations. And what should be the final result?

## Products

No products are associated with this question.

### Walter Roberson (view profile)

on 5 Feb 2013

```R = randn(1,50);
for K = 1 : 10
R = [R, randn(1,length(R))];
fprintf('new size is %d\n', length(R))
end
```

#### Join the 15-year community celebration.

Play games and win prizes!

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi