find in structure a certain string

조회 수: 1 (최근 30일)
Leonardo Wayne
Leonardo Wayne 2016년 4월 15일
댓글: Leonardo Wayne 2016년 4월 18일
raw is a cell.
I would like to find the identification number in the example which is 13161509800019, but I only want the cell that contains 1-2-3, as the cell below it contains a trailing 4-5-6. Also how can I do that for any number of identification numbers containing 1-2-3 column 1 excluding first row 'SERIAL'?

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 15일
편집: Azzi Abdelmalek 2016년 4월 15일
C={'serial';'123456 1-2-3';'1452145 4-5-6';'745841 3-2-4';'85471245 1-2-3'}
C=C(2:end);
idx=~cellfun(@isempty,regexp(C,'1-2-3'))
D=C(idx)
out=regexp(D,'.+(?=1-2-3)','match')
out=str2double([out{:}])
  댓글 수: 2
Leonardo Wayne
Leonardo Wayne 2016년 4월 18일
Hi Azzi, thanks for the answer. I am stuck with another issue. If you take a look the images 1-4. The cell "get_motors_no_workbook2_NO_123" being created in image 1 has two index numbers when I click on the cell values and reach the image 4. How can that be, does this mean that this is a cell inside another cell?
Also, if I want "get_motors_no_workbook2_NO_123" to have only 6x1 cell and those individual rows in image 2 to be char values as shown in 4 not 1x1 cell as is shown in 3.
In other words: e.g. refer to image 2: I want row 1 which is '13161509800019' to be a char and not a 1x1 cell and so on. Image 1 has the code!
<<
>>
Leonardo Wayne
Leonardo Wayne 2016년 4월 18일
never mind. I have solved it.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Feature Detection and Extraction에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by