Home > functions > device > location_device > digitizer > vb_read_stylus.m

vb_read_stylus

PURPOSE ^

Read FastScan point data file

SYNOPSIS ^

function Data = vb_read_stylus(fname)

DESCRIPTION ^

 Read FastScan point data file
  Data = read_stilus(fname)
 Data  : point coordinate [Npoint 3]

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function    Data = vb_read_stylus(fname)
0002 % Read FastScan point data file
0003 %  Data = read_stilus(fname)
0004 % Data  : point coordinate [Npoint 3]
0005 %
0006 % Copyright (C) 2011, ATR All Rights Reserved.
0007 % License : New BSD License(see VBMEG_LICENSE.txt)
0008 
0009 key  = '%';
0010 
0011 % Find keyward line
0012 fid=fopen(fname);
0013 
0014 if fid == -1, fprintf('[%s] can not be opened\n',fname);return; end;
0015 
0016 Nline = 0;
0017 
0018 while 1
0019     next_line = fgetl(fid);
0020     if ~ischar(next_line), break, end;
0021     if isempty( strfind(next_line,key)), break, end;
0022     Nline=Nline+1;
0023 end
0024 
0025 fclose(fid);
0026 
0027 fid=fopen(fname);
0028 
0029 for n = 1:Nline
0030     next_line = fgetl(fid);
0031 end
0032 
0033 % from here on it's just data
0034 
0035 Data = fscanf(fid,'%f',Inf);
0036 
0037 fclose(fid);
0038 
0039 [N M] = size(Data);
0040 Ndata = N*M/6;
0041 
0042 Data = reshape(Data, [6 Ndata]);
0043 Data = Data';
0044 Data = Data(:,1:3);
0045

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005