MATLAB: Split up file name into strings…

file name split

Well I have a file name that I need to split up into 2 main parts and then put them into matlab as numbers.
The average name of the file is:
curr_1.564_image_002.tiff
I need:
curr = 1.564
image = 2
Here is what I have right now, this is really ugly way of doing this…
[~,o,p] = fileparts(fig_dir(1).name);
[k y] = strtok(o,'_');
y = y(2:end);
[curr z] = strtok(y,'_');
image = z(8:end);
If I can split up this file name into these two parts that is all I need. I was unsure how to do this in MATLAB. Thank you, Chris

Best Answer

And another approach:
name = 'curr_1.564_image_002.tiff';
numbers = sscanf(name, 'curr_%g_image_%d');