i have a cell u(38,1) each row has string looking like this : for example
u{1,1} = ''198823 765389 white''
u{2,1} = ''198426 725312 black''
I want the cell u to be divided in 3 colomns such as
u{1,1} = ''198823'' u{1,2}= ''765389'' u{1,3}=''white''
u{2,1} = ''198426'' u{2,1}= ''725312'' u{2,3}=''black''
so basically I want my u(38,1) to become u(38,3)
I have tried strplit, but it seems like it won't work with a cell,
strplit(u,',') %doesn't work'
strplit(u{1,1},',') %works on the first line and returns a cell (1,3)
%simplest solution is using a for loop to split one by one
clear
clc
u{1,1}="198823 765389 white";
u{2,1}="198426 725312 black";
for i=1:length(u)
tokens=strsplit(u{i});
u{i,1}=tokens(1);
u{i,2}=tokens(2);
u{i,3}=tokens(3);
end
disp(u)
Get Answers For Free
Most questions answered within 1 hours.