Error in extract_db (line 47) file_a = extractAft​er(char(fi​le_a), 0, strfind(char(file_a), '_')-2);

'101_1.tif' '101_2.tif' '101_3.tif' '101_4.tif' '101_5.tif' '101_6.tif' '101_7.tif' '101_8.tif' '102_1.tif' '102_2.tif' '102_3.tif' '102_4.tif' '102_5.tif' '102_6.tif' '102_7.tif' '102_8.tif' '103_1.tif' '103_2.tif' '103_3.tif' '103_4.tif' '103_5.tif' '103_6.tif' '103_7.tif' '103_8.tif' '104_1.tif' '104_2.tif' '104_3.tif' '104_4.tif' '104_5.tif' '104_6.tif' '104_7.tif' '104_8.tif' '105_1.tif' '105_2.tif' '105_3.tif' '105_4.tif' '105_5.tif' '105_6.tif' '105_7.tif' '105_8.tif' '106_1.tif' '106_2.tif' '106_3.tif' '106_4.tif' '106_5.tif' '106_6.tif' '106_7.tif' '106_8.tif' '107_1.tif' '107_2.tif' '107_3.tif' '107_4.tif' '107_5.tif' '107_6.tif' '107_7.tif' '107_8.tif' '108_1.tif' '108_2.tif' '108_3.tif' '108_4.tif' '108_5.tif' '108_6.tif' '108_7.tif' '108_8.tif' '109_1.tif' '109_2.tif' '109_3.tif' '109_4.tif' '109_5.tif' '109_6.tif' '109_7.tif' '109_8.tif' '110_1.tif' '110_2.tif' '110_3.tif' '110_4.tif' '110_5.tif' '110_6.tif' '110_7.tif' '110_8.tif'
I have the Img names "101_1",
and I want to extract the substring
included between the underscore '_'.
Here I used,
file_a = extractAfter(char(file_a), 0, strfind(char(file_a), '_')-2);
but it produces error,
I want as output 102_1 and so on.
How can I do this? thanks

 채택된 답변

Walter Roberson
Walter Roberson 2018년 11월 21일
fileparts()
You do not indicate what the error is .I suspect you are using r2016a or earlier before extractAfter existed

댓글 수: 6

Error using extractAfter
Too many input arguments.
Error in extract_db (line 47)
file_a = extractAfter(char(file_a), 0, strfind(char(file_a), '_')-2);
i am using r2016a matlab
extractAfter did not exist in your release so you are invoking some other routine that happens to have the same name .
Atleast give some hint todo following statement
char(file_a), 0, strfind(char(file_a), '_')-2
myprogram executes file 101_1 to 101_8 but when loop comes on 102_1 am getting above
error, how to execute
char(file_a), 0, strfind(char(file_a), '_')-2
in r2016a release.
I gave the hint already . fileparts()
file_a = regexprep(file_a, '\..*$', '');
This will work whether file_a is a cell array of character vectors or a single character vector -- in other words it can be applied to the complete list of filenames all at the same time.

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

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by