for k = 1:length(lx) dist_mat_new(k,linear_index) = distance_prime_new(k,:)'; end
so to clarify, linear_index is a vector that contains all the linear indices of a 97x97x32 array. What I am trying to do is to put each row of distance_prime_new into dist_mat_new, where dist_mat_new(1,:,:,:) will be filled with the first row of distance_prime_new. The linear index of the elements in distance_prime_new is given by the value in linear_index at the column of distance_prime_new, i.e. the linear_index for all values at distance_prime_new(:,234) is found at linear_index(234).
Just want to use a better commmand as opposed to a for loop.