How to create the following cell array with the following pattern quickly
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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]
3 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 30 Aug. 2012
m = {'s' 'o' 'd' 'p' 'x' '+' '*' '>'};
idx = hankel(1:numel(m),[numel(m) 1:numel(m)-1]);
marker = m(idx(:)');
2 Kommentare
Oleg Komarov
am 30 Aug. 2012
Bearbeitet: Oleg Komarov
am 30 Aug. 2012
Another solution based on the circulant matrix:
idx = fliplr(gallery('circul',numel(m):-1:1));
marker = m(idx(:)');
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!