How to convert single column into multiple column having different spacing
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Shelender Kumar
el 29 de Oct. de 2018
Comentada: Shelender Kumar
el 2 de Nov. de 2018
Hi, I have a data file which is quite big, I want to reshape my data file but problem is that my data point is not uniformly spaced. For example, in this case, I want to have 1500 rows and 300 columns and each column must start from different temperature as in the first column of the raw file.
M = dlmread('MHfinal.dat', '', 2, 0); %%2, 0 represent from you want to start.
M1 = reshape(M,1542,7);
0 comentarios
Respuesta aceptada
Walter Roberson
el 29 de Oct. de 2018
uniquetol() applied to the temperature column. The third output is the grouping variable. Use
Output = accumarray(TheGroupingVariable, ThirdColumn, [], @(v){v.'});
If the resulting cell array happens to have the same number of entries in each cell then cell2mat. But it looks to me as if that is not likely to be the case: it looks to me as if your first temperatures do not repeat.
10 comentarios
Walter Roberson
el 2 de Nov. de 2018
Do you want separate variables
Output_1 = [Output2(:,1), Output3(:,1)];
Output_2 = [Output2(:,2), Output3(:,2)];
Output_3 = [Output2(:,3), Output3(:,3)];
...
Output_7 = [Output2(:,7), Output3(:,7)];
Or do you want a single array,
Output = [Output2(:,1), Output3(:,1), Output2(:,2), Output3(:,2), Output2(:,3), Output3(:,3), ... Output2(:,7), Output3(:,7)];
The code I posted for combined builds the second of those possibilities.
Más respuestas (0)
Ver también
Categorías
Más información sobre Characters and Strings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!