How to create the following cell array with the following pattern quickly
1 view (last 30 days)
Show older comments
Hi,
I would like to create the following cell array quickly without explicitly stating the elements as I am doing now:
marker = {'s','o','d','p','x','+','*','>', ...
'o','d','p','x','+','*','>','s', ...
'd','p','x','+','*','>','s','o', ...
'p','x','+','*','>','s','o','d', ...
'x','+','*','>','s','o','d','p', ...
'+','*','>','s','o','d','p','x', ...
'*','>','s','o','d','p','x','+', ...
'>','s','o','d','p','x','+','*'}
As you can see there is a pattern here, there are 8 unique marker types and each consecutive group of 8 markers is based on the first 8 markers...I am new to matlab and would like to know if there is any intrinsic function that I could use or some sort of looping algorithm to create this cell array. I ask because I may need a larger cell array down the road and I think this is inefficient.
[EDITED, Jan, format improved]
Accepted Answer
Andrei Bobrov
on 30 Aug 2012
m = {'s' 'o' 'd' 'p' 'x' '+' '*' '>'};
idx = hankel(1:numel(m),[numel(m) 1:numel(m)-1]);
marker = m(idx(:)');
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!