How to save values of x for condition below and assign y to them to find its length
    for i=1:100
    n=1;
    x(i)=rand
    if x>0.5
    y=x;
    end
    length(y)
    end
How to save values of x for condition below and assign y to them to find its length
    for i=1:100
    n=1;
    x(i)=rand
    if x>0.5
    y=x;
    end
    length(y)
    end
 
    
    You don't need a loop here. Do the following:
x = rand(1,100); %Storing all values at once
y = x(x>0.5);    %Storing values of x greater than 0.5 in y
length(y)        %Finding the length of y
Suggested reading:
                       Matrix Indexing in MATLAB
by Steve Eddins and Loren Shure (MathWorks)
