m = zeros(1,163);count = 1;flag= 0;while 1 r = randi([1,326]); for i = 1:1:count if(m(1,i)==r) flag = 1; end end if(flag==0) m(1,count)=r; count=count+1; end if(count==163) break; endend
MATLAB: Why this code is not running ? the workspace remains empty.
matrix
Related Question
- Finding elements in an array that differ by a certain tolerance from elements in another array of different size
- How do you rewrite the nested if statement as a loop
- I have a string S=’010101′ I need to take each element from the string and check whether it 1,if it is one then the count is incremented by one in matlab
- Help in making a cumulative histogram, histc or accumarray
- I am trying to store the (non-repetitive) numbers in B = [3,5] after factorizing 225 = 3 x 3 x 5 x 5, but executing the code it stores only one, i.e. B = [3].
Best Answer