I am importing data from a txt file that has a column list of values. I would like to populate a matrix with these values in a looped way so that the matrix fills each column in a row with consecutive values from the txt list, then moves to the next row to fill each column with the next set of values, and so on. I need this to work with any number of values and matrix size, so that if there are a total of m*n values in the column list, the matrix produced will be of size m x n.
The data is read from a txt file comprising 4 columns of information, of which I am only interested in the 4th. The order of population is critical as two of the list columns give x & y spatial coordinates that are associated with each of the values in the 4th column.
Currently my code looks like this:
W = importdata('307_6_5.txt',' ',8);
hor_el = 6;
ver_el = 5;
MODE = zeros(ver_el+1, hor_el+1);
for k = 1:(hor_el+1)*(ver_el+1)
for i = 1:ver_el + 1;
for j = 1:hor_el + 1;
MODE(i,j) = W.data(k, 4);
I know this will be embarrassingly simple for someone who knows what they are doing but unfortunately my Matlab skills are still very poor. Any help would be much appreciated.