Shifting or sorting arrays with specific names
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Praveen Choudhury
am 5 Jan. 2016
Kommentiert: Ingrid
am 6 Jan. 2016
I have a cell array of 1000*1 dimension with names on it. I want to shift my elements in such a way that the name starting with N and ending with CA goes to the end. How can I do it?
0 Kommentare
Akzeptierte Antwort
Ingrid
am 5 Jan. 2016
you could use arrayfun to extract the first and last two letters and then use strfind to locate the index at which the letters that you want and then use this index for the shifting
firstLetter = arrayfun(@(n) cellArrayNames{n}(1),1:size(cellArrayNames,1),'UniformOutput',0);
lastTwoLetters = arrayfun(@(n) cellArrayNames{n}(end-2:end),1:size(cellArrayNames,1),'UniformOutput',0);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays 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!