필터 지우기
필터 지우기

Can I split an array by a specific word?

조회 수: 3 (최근 30일)
Gmc
Gmc 2015년 3월 1일
편집: per isakson 2015년 3월 2일
Hello everyone - I have a large messy excel worksheet which includes a lot of text. I have read in a specific column using xlsread and I need to count the number of times a certain word appears within that column. The problem is there are multiple output files from another program saved to this same excel sheet. I need to count these words for each file. The columns I need to analyze are always the same, but the number of rows is always different. For example column E which is now a cell array in matlab includes output from three different files and I need to separate the array somehow into three different arrays. The only thing that is consistent in these excel sheets is when a new file is being coded in the other program a code appears in the excel column which reads VTNxxx. Therefore, is there someway to split this array by that specific word?
thank you - any suggestions would be appreciated.

답변 (1개)

per isakson
per isakson 2015년 3월 1일
편집: per isakson 2015년 3월 2일
Try
>> cac = strsplit('Can I split an array by a specific word?', 'array')
cac =
'Can I split an ' ' by a specific word?'
Then try this
str = 'Can I split an array by a specific word?';
cac = strsplit( str, 'array' );
cell_array = strsplit( str, ' ' );
ix = find( strcmp( 'array', cell_array ) );
head = cell_array( 1 : ix-1 );
tail = cell_array( ix+1 : end );

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by