]> Creatis software - CreaPhase.git/blob - utilities_ESRF/headerstring.m
useful functions for simulations, created by ESRF people mainly (free to use)
[CreaPhase.git] / utilities_ESRF / headerstring.m
1 ## function str=headerstring(what,value,kind)
2 ## used by writeheader
3 ## returns a string for incorporation in an edf-header
4 ## what is the information item (e.g. 'Dim_1')
5 ## value of the item
6 ## kind is string, char, integer, logical, float or double
7 ## origin: peter
8 ##
9 ## 30.09.2009 (HSu): Updated to work with double and char data types
10 ## 2011-08-29 PC
11 ## * add logical data type
12
13 function str=headerstring(what,value,kind)
14   
15   str=[what ' = '];
16
17   switch kind
18     case {'string', 'char'},
19       str=[str sprintf('%s ',value')];
20     case {'integer', 'logical'},
21       str=[str sprintf('%i ',value')];
22     case {'float', 'double'}
23       str=[str sprintf('%g ',value')];
24     otherwise
25       printf("Unknown data type in header %s\n",kind);
26   end
27   
28   str = [str sprintf(';\n')];
29 end