Home > . > stra2num.m

# stra2num

## PURPOSE

'stra2num': transform letters (a, b, c) or numerical strings ('1','2'..) to the corresponding numbers

## SYNOPSIS

function numres=stra2num(str)

## DESCRIPTION

    'stra2num': transform letters (a, b, c) or numerical strings ('1','2'..) to the corresponding numbers
    --------------------------------------------
      function numres=stra2num(str)

     OUTPUT:
     numres: number (double)

     INPUT:
     str: string corresponding to a number or a letter 'a' 'b',.., otherwise the output is empty

     see also num2stra, name_generator, name2display

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- civ 'civ': function associated with the interface 'civ.fig' for PIV, spline interpolation and stereo PIV (patch)
- civ_3D 'civ_3D': function associated with the interface 'civ_3D.fig' for PIV in volume
- name_generator 'name_generator': creates a file name from a root name and indices.
- series 'series': master function associated to the GUI series.m for analysis field series
- uvmat 'uvmat': function associated with the GUI 'uvmat.fig' for images and data field visualization

## SOURCE CODE

    0001 %'stra2num': transform letters (a, b, c) or numerical strings ('1','2'..) to the corresponding numbers
    0002 %--------------------------------------------
    0003 %  function numres=stra2num(str)
    0004 %
    0005 % OUTPUT:
    0006 % numres: number (double)
    0007 %
    0008 % INPUT:
    0009 % str: string corresponding to a number or a letter 'a' 'b',.., otherwise the output is empty
    0010 %
    0011 % see also num2stra, name_generator, name2display
    0012
    0013 function numres=stra2num(str)
    0014 numres=[]; %default
    0015 if double(str) >= 48 & double(str) <= 57 % = test for number strings
    0016     numres=str2num(str);
    0017 elseif double(str) >= 65 & double(str) <= 90 % test on ascii code for capital letters
    0018     numres=double(str)-64; %change capital letters to corresponding number in the alphabet
    0019 elseif double(str) >= 97 & double(str) <= 122 % test on ascii code for small letters
    0020     numres=double(str)-96; %change small letters to corresponding number in the alphabet
    0021 end