Sontakke B M
Sontakke B M

Reputation: 9

Instead of substring() function what can I use in matlab R2016b

I want to implement the following statement in Matlab R2016b

file_a = substring(char(file_a), 0, findstr(char(file_a), '_')-2);

Here, file_a having 101_1 to 101_8, 102_1 to 102_8 and so on.

substring() is not evaluated in the R2016b release.

Upvotes: 1

Views: 58

Answers (1)

user7431005
user7431005

Reputation: 4539

What exactly is your expected result?

file_a = '101_1'
file_a = extractAfter(file_a,strfind(file_a,'_')-2)

this code produces a file_a of '1_1'.

file_a = '101_1'
file_a = extractBefore(file_a,strfind(file_a,'_')-1)

this code produces a file_a of '10'

file_a = '101_1'
file_a = extractBetween(file_a,strfind(file_a,'_')-1,strfind(file_a,'_'))

this code produces a file_a of '1_'

Upvotes: 1

Related Questions