in R2023a, A text file, containing huge data in one column,How arrange data in 6 colum.where The first six number at the first Row and second six number in second Row.
1 view (last 30 days)
Show older comments
in R2023a, A text file, containing huge data in one column,How arrange data in 6 colum.where The first six number at the first Row and second six number in second Row.....
0 Comments
Accepted Answer
Stephen23
on 3 May 2023
F = 'the name fo your file';
M = readmatrix(F);
M = reshape(M,6,[]).'
2 Comments
More Answers (1)
Mathieu NOE
on 3 May 2023
hello
to load your text file use readmatrix
then you can use this demo code below to shape the data in 6 columns
as the data length may not be an exact multiple of 6 here I padded the data (28 values) with zeroes at the end to have at the end 30 samples (5 rows). You may want another value or NaN if you prefer
a = (1:28)' % dummy data vector (column)
cols = 6; % how many columns ?
%% main code
samples = numel(a);
rows = ceil(samples/cols); % compute how many rows are needed
% padd data to fill all rows
tmp = zeros(cols*rows,1);
tmp(1:samples) = a;
% reshape the data
b = reshape(tmp,cols,rows);
% flip dimensions
c = b'
0 Comments
See Also
Categories
Find more on Workspace Variables and MAT-Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!