Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

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?

Asked by Conor 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!

2 Comments

bym 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 on 5 Feb 2013

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

Conor

Products

No products are associated with this question.

1 Answer

Answer by Walter Roberson 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

0 Comments

Walter Roberson

Contact us