Lets say I have n*m matrix. For each row I would pick a random starting point and change the values from that point to the end of the row.
x=ones(n,m);T=randsample(m,n); %starting points for each row
End=m*ones(size(T)); %ending points for each row
x(:,T:End)=0 %This doesn't work but something like that
Eg:
magic(5);T=randsample(5,5);T = 2 3 1 5 4 %Now I want to make every value from T to end in X=0
for i=1:5 x(i,T(i):end)=0 end
Is there a way to vectorize this. If I'm simulating a million trials using a for loop is not very efficient.
Best Answer