Iteration across numerous columns
Mostrar comentarios más antiguos
alumina 80 is a matrix of 11143 x 12.
The columns are in pair of (viscosity and temperature) making six pairs. There are multiple entries as well which i need to find the mean and return the answers in two separate columns. I have accomplished this with the code below for a single pair (viscosity and temp).
[u,~,ix] = unique(zz(:,2));
b = [u,accumarray(ix,zz(:,1))./accumarray(ix,1)];
(Note: here zz is a .csv file imported into matlab as a matrix of 11148x2 size).
My next task is to work through column 1&2, 3&4, 5&6, 7&8, 9&10, and 11&12 in that order in a single .csv file imported into MATLAB as matrix of 11143 x 12 size. I also need to return each pair as the code above will do for a single pair of columns.
I tried this code:
[r, c] = size(m);
for t=2:2:c;
for k=1:2:c;
[u,~,ix] = unique(m(:,t));
b = [u,accumarray(ix,m(:,k))./accumarray(ix,1)];
display (b)
end
end
But this didn't work out for me.
Any help please. A sample file has been attached.
Thanks in advance
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!