Azzera filtri
Azzera filtri

How to convert single column into multiple column having different spacing

8 visualizzazioni (ultimi 30 giorni)
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);

Risposta accettata

Walter Roberson
Walter Roberson il 29 Ott 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 Commenti
Walter Roberson
Walter Roberson il 2 Nov 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.

Accedi per commentare.

Più risposte (0)

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by