i have vector 100000*1 .i want to randomly divide data of it into 80% and 20% and store them into 2 vector.Divide of data must be random.
"non_zero_entry" is total how many entry in the vector.i tried to do this but it show me error "Index exceeds the number of array elements (80000)".
training_data=.8;tf = false(length(non_zero_entry),1);tf(1:round(training_data*non_zero_entry)) = true;tf = tf(randperm(non_zero_entry)); % error occur in this line "Index exceeds the number of array elements (80000)".
dataTraining = index_rating(tf,:); dataTesting = index_rating(~tf,:);
Thanks in advance for your help.
Best Answer