IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
gendata.m
Go to the documentation of this file.
1 %>@file
2 %>@ingroup guigroup ioio misc graphicsapi interactive
3 %>@brief Lets the user create a dataset by clicking the mouse and pressing the number keys
4 colors = 'rbmk';
5 markers = 'pso<';
6 
7 figure;
8 set(gca, 'xlim', [0, 10], 'ylim', [0, 10]);
9 title('0, 1, 2, 3 for class or E to end');
10 hold on;
11 
12 k = 0;
13 class = 0;
14 clear classes_ X;
15 while 1
16  [x,y, z] = ginput(1);
17 
18  if z == 1
19  k = k+1;
20  X(k, :) = [x, y];
21  classes_(k, 1) = class;
22 
23 
24  plot(x, y, 'Color', colors(class+1), 'Marker', markers(class+1));
25  hold on;
26  set(gca, 'xlim', [0, 10], 'ylim', [0, 10]);
27  else
28  if z >= 48 && z <= 51
29  class = z-48;
30  elseif z == 'E' || z == 'e'
31  disp('Ok');
32  break;
33  end;
34  end;
35 end;
36 
37 if k > 1
38  data = irdata();
39  data.X = X;
40  data.classes = classes_;
41  data = data.assert_fix();
42  f = find_filename('gendata', '', 'txt');
43  oio = dataio_txt_basic();
44  oio.filename = f;
45  oio.save(data);
46  disp(['Saved file ' f]);
47 end;
Dataset class.
Definition: irdata.m:30
Basic TXT loader/saver.
function find_filename(in prefix, in suffix, in extension, in flag_return_ext)