]> Creatis software - CreaPhase.git/blobdiff - utilities_ESRF/headerstring.m
useful functions for simulations, created by ESRF people mainly (free to use)
[CreaPhase.git] / utilities_ESRF / headerstring.m
diff --git a/utilities_ESRF/headerstring.m b/utilities_ESRF/headerstring.m
new file mode 100644 (file)
index 0000000..a7d7083
--- /dev/null
@@ -0,0 +1,29 @@
+## function str=headerstring(what,value,kind)
+## used by writeheader
+## returns a string for incorporation in an edf-header
+## what is the information item (e.g. 'Dim_1')
+## value of the item
+## kind is string, char, integer, logical, float or double
+## origin: peter
+##
+## 30.09.2009 (HSu): Updated to work with double and char data types
+## 2011-08-29 PC
+## * add logical data type
+
+function str=headerstring(what,value,kind)
+  
+  str=[what ' = '];
+
+  switch kind
+    case {'string', 'char'},
+      str=[str sprintf('%s ',value')];
+    case {'integer', 'logical'},
+      str=[str sprintf('%i ',value')];
+    case {'float', 'double'}
+      str=[str sprintf('%g ',value')];
+    otherwise
+      printf("Unknown data type in header %s\n",kind);
+  end
+  
+  str = [str sprintf(';\n')];
+end