source: trunk/src/num2stra.m @ 1195

Last change on this file since 1195 was 1194, checked in by sommeria, 8 days ago

several bugs repaired

File size: 1.8 KB
Line 
1%'num2stra': transform number to the corresponding character string depending on the nomenclature
2%--------------------------------------------
3% function str=num2stra(num,nom_type,index)
4%
5% OUTPUT:
6% str: character string
7%
8% INPUT:
9% num: input number (file index)
10% nom_type: nomenclature type (see fct name_generator)
11% index: 1 or 2 (first or second index in file naming)
12% see also: stra2num, name_generator, name2display
13
14%=======================================================================
15% Copyright 2008-2024, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
16%   http://www.legi.grenoble-inp.fr
17%   Joel.Sommeria - Joel.Sommeria (A) univ-grenoble-alpes.fr
18%
19%     This file is part of the toolbox UVMAT.
20%
21%     UVMAT is free software; you can redistribute it and/or modify
22%     it under the terms of the GNU General Public License as published
23%     by the Free Software Foundation; either version 2 of the license,
24%     or (at your option) any later version.
25%
26%     UVMAT is distributed in the hope that it will be useful,
27%     but WITHOUT ANY WARRANTY; without even the implied warranty of
28%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29%     GNU General Public License (see LICENSE.txt) for more details.
30%=======================================================================
31
32function str=num2stra(num,nom_type,index)
33str='';
34if ~exist('index','var')
35    index=2; %index 1 or 2 of the file indices
36end
37switch index
38    case 1
39           str=num2str(num);
40    case 2
41        if ~isempty(nom_type) && (isequal(nom_type(end),'a')||isequal(nom_type(end),'b'))
42            str=char(96+num);
43        elseif ~isempty(nom_type) && (isequal(nom_type(end),'A')||isequal(nom_type(end),'B'))
44            str=char(64+num);
45        else
46            str=num2str(num);
47        end
48end
Note: See TracBrowser for help on using the repository browser.