changing the string "JF 2009" to two seperate strings "J 2009" " F2009"
Show older comments
Dear all I have the following cell matrix
A={
1 'SLO' ' '
1 'SLO' ' '
1 'SLO' 'JF 2009'
1 'SLO' 'MA 2009'
1 'SLO' 'MJ 2009'
1 'SLO' 'JA 2009'
1 'SLO' 'SO 2009'
1 'SLO' 'ND 2009'
1 'SLO' 'JF 2010'
1 'SLO' 'MA 2010'
1 'SLO' 'MJ 2010'
1 'SLO' 'JA 2010'
1 'SLO' 'SO 2010'
1 'SLO' 'ND 2010'
1 'SLO' 'JF 2011'
1 'SLO' 'MA 2011'
1 'SLO' 'MJ 2011'
1 'SLO' 'JA 2011'
2 'SLO' ' '
2 'SLO' ' '
2 'SLO' 'JF 2009'
2 'SLO' 'MA 2009'
2 'SLO' 'MJ 2009'
2 'SLO' 'JA 2009'
2 'SLO' 'SO 2009'
2 'SLO' 'ND 2009'
2 'SLO' 'JF 2010'
2 'SLO' 'MA 2010'
2 'SLO' 'MJ 2010'
2 'SLO' 'JA 2010'
2 'SLO' 'SO 2010'
2 'SLO' 'ND 2010'
2 'SLO' 'JF 2011'
2 'SLO' 'MA 2011'
2 'SLO' 'MJ 2011'
2 'SLO' 'JA 2011'
}
As you can see I have bimontly data. I want to modify the last column so as to have months like
Amodified={
1 'SLO' ' '
1 'SLO' ' '
1 'SLO' 'J 2009'
1 'SLO' 'F 2009'
1 'SLO' 'M 2009'
1 'SLO' 'A 2009'
1 'SLO' 'M 2009'
1 'SLO' 'J 2009'
1 'SLO' 'J 2010' }
and so forth
Is there any "clever code to do that?
NOte that the fist column represents the individual. In my real matrix I have 30000 individuals.
thanks in advance
Accepted Answer
More Answers (1)
Wayne King
on 25 Jul 2012
Edited: Wayne King
on 25 Jul 2012
One way:
Amodified = A;
B = char(A(:,3));
B(:,2) = [];
B = cellstr(B);
Amodified(:,3) = B;
4 Comments
salva
on 25 Jul 2012
Wayne King
on 25 Jul 2012
" adjust columns 1 and 2 to the modified-extended column 3?" I'm not sure what you mean here
salva
on 25 Jul 2012
Wayne King
on 25 Jul 2012
It's a cell array so why do you have to adjust the "dimension" of the other columns, they aren't equal to begin with
size(A{1,1}), size(A{1,2})
Categories
Find more on Startup and Shutdown 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!