data from first line to two column

1 view (last 30 days)
I have data.txt. There is lot of numbers, in this format (1.4282E-01, 5.0537E+00, 1.2573E-01, 5.0537E+00, 1.8311E-02, 5.0513E+00,...n) all is in one line.
I need transform:
1.4282E-01, 5.0537E+00,
1.2573E-01, 5.0537E+00,
1.8311E-02, 5.0513E+00,
.
.
.
n
I write this code, but calculate is very long and not end.
data.txt
A=data;
n=643968;
index_i=1:2:n;
index_j=1:1:n/2;
for i=index_i;
j=index_j;
B(j,1)=A(1,i);
end
??? I need A(1,1)=B(1,1); A(1,3)=B(1,2); A(1,5)=B(1,3);
please help me

Accepted Answer

Stephan
Stephan on 29 Mar 2019
A=[1.4282E-01, 5.0537E+00, 1.2573E-01, 5.0537E+00, 1.8311E-02, 5.0513E+00];
B=reshape(A,2,[])'

More Answers (0)

Tags

Products

Community Treasure Hunt

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

Start Hunting!