I imported two columns of data from a txt file but it came in as one column who can i split them up

2 views (last 30 days)
Is there a function i can use to split the dingle columns in two. I tried calculating the remainder of each entry number ( 1 2 3 4 etc) and moving into a separate matrix but it did not work. here is my code:
- A is a 1x12882 matrix where the odd number should be in the Thick column and the even numbers should be in the Thin columns
for i = length(A)
t= rem(i,2);
if t == 1
Thick(i)=A(i);
else
Thin(i) = A(i);
end
end
t=5

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 5 May 2015
a=[1;2;4;6;5;1;2;7;8;10]
idx=rem(a,2)==1
a1=a(idx)
a2=a(~idx)

More Answers (0)

Community Treasure Hunt

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

Start Hunting!