MATLAB: How to extract only floating numbers from a string

extract numberssscanfstrings

Here is my string "21.5VgDC_0.05000V_VgAC_50M-150M30ms47GV1" How can I extract only the numbers 21.5, 0.05000, 50, 150 30 and 47 from the string. Thanks in advance

Best Answer

>> S = '21.5VgDC_0.05000V_VgAC_50M-150M30ms47GV1';
>> C = regexp(S,'\d+\.?\d*','match');
>> C{:}
ans = 21.5
ans = 0.05000
ans = 50
ans = 150
ans = 30
ans = 47
ans = 1