Shifting or sorting arrays with specific names

조회 수: 3 (최근 30일)
Praveen Choudhury
Praveen Choudhury 2016년 1월 5일
댓글: Ingrid 2016년 1월 6일
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?

채택된 답변

Ingrid
Ingrid 2016년 1월 5일
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);
  댓글 수: 2
Praveen Choudhury
Praveen Choudhury 2016년 1월 5일
How do I shift to the end, having got the index?
Ingrid
Ingrid 2016년 1월 6일
cellArray(end,1) = cellArray(idx,1);
cellArray(idx,1) = [];

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by