MATLAB: How to convert string to number and process underscores? (e.g. ’57_77_’ to 57.77)

data processingMATLAB and Simulink Student Suitenumberstring

How do you convert a string with underscores to a number, namely '57_77_' to 57.77? What commands would you use?
I am looking through the documentation, e.g. join, compose, sprintf, extractBefore, trying to figure out how to process such a string, namely to execute the steps:
  1. delete final '_'
  2. convert '_' to decimal point '.'
  3. convert string to number

Best Answer

Faster and more efficient than using str2num (which hides a slow eval call inside) is to simply use the low-level function sscanf:
>> sscanf(strrep('57_77_','_','.'),'%f')
ans = 57.770
This is ten times faster than the accepted answer (1e4 iterations):
Elapsed time is 0.277028 seconds. % my code
Elapsed time is 2.63426 seconds. % accepted answer