vec= [1 1 1 1 3 1 4 1 1 5 5]';myOffset=0.05;nonOnes=find(vec>1); % Find elements > 1
N=vec(nonOnes); % Create vector with elements > 1
i=1;n=1;counter=1;while n<=N(i) myOrder(counter)=(n/(N(i)+1))*(1 + myOffset*randn(1));n=n+1;counter=counter+1;end
Here is my problem: In the code, I wrote i=1 to make it program function somehow. But in reality "i" should be in the range of i=1:length(N), and I do not know how to make the wile loop function for every N(i). The vector myOrder should store 17 elements if the while loop iterates for each element N(i), but I get only 3 with this code. "n" starts with the value of one until it reaches the value of N(i).
Best Answer