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?

2 views (last 30 days)
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
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
Azzi Abdelmalek on 5 Feb 2013
Edited: 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?

Sign in to comment.

Answers (1)

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

Categories

Find more on Loops and Conditional Statements 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!