0

txt file content : 2;123687452321215454 I would like to get the fist character "2"

I tried :

s = fileread(filepath);
[token, remain] = strtok(s)
token =
this returns :
token =

2;123687452321215454
remain =

how could I get only the first "2" ?

4

1 回答 1

2

If you want to get whatever is before the ;, use:

[token, remain] = strtok(s,';')

This will give you more than one character if that's what there is before the ;. If you just want the first character, use token(1). If you want the last character before the ; use token(end).

于 2013-09-20T11:06:21.783 回答