MATLAB: How to extract values from a string.

charstrings

So I have a string in the following format:
filename = "Delft_2_220_20_4344-5088.csv" ;
And I want to extract the numbers from it, what is a good way to do this?
So the result is something like this:
a=2; b=220; c=20;d=[4344 5088];

Best Answer

>> S = 'Delft_2_220_20_4344-5088.csv';
>> V = str2double(regexp(S,'\d+','match'))
V =
2 220 20 4344 5088
Using indexing to allocate those values to whatever other variables you want.