Filter löschen
Filter löschen

How to convert single column into multiple column having different spacing

8 Ansichten (letzte 30 Tage)
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);

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 29 Okt. 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 Kommentare
Walter Roberson
Walter Roberson am 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by