PDA

View Full Version : Interface to Matlab



Somesh
2008-10-21, 13:54
MovAlyzeR records x,y coordinate data and pressure, tilt(optional) and stores them in .hwr files. These are simple space separated ASCII files and can be read into Matlab or any other programming environment.


Provided is a rudimentary example of how to read a raw hwr data file from MovAlyzeR into Matlab. Please check back soon for Matlab functions to read other files output from MovAlyzeR (tf, seg, ext, inc etc)


% This Matlab program reads the raw x,y,z and tilt data (azimuth and altitude)
% from the .hwr file recorded by MovAlyZeR(c). This data file can be accessed at the location
% UserRootDir\Experiment\Group\Condition\Subject\[.hwr file]

hwrdata = dlmread('C:\USR\EXP\GRP\CON\SUB\EXPGRPCONSUB01.HWR ');

% The columns of hwrdata have the raw coordinates, pressure and tilt information
x = hwrdata(:,1);
y = hwrdata(:,2);
z = hwrdata(:,3);
tilt_azimuth = hwrdata(:,4); <=== Optional in 4.9 and later
tilt_altitude = hwrdata(:,5); <=== Optional in 4.9 and later

% Now you can use the data as you like...
% eg : Plot x vs y
plot(x,y);

Somesh
2009-07-14, 13:57
The following is a straightforward implementation of reading .TF files into Matlab, then writing them to a Microsoft Excel spreadsheet.


function tfparse(filename)
% This program parses a .tf file (output from Movalyzer) and saves the
% data in an Excel readable file.

fin = fopen(filename,'r');
% Read line-by-line. Number of parameters is fixed for simplicity.
for i=1:18
% Strip the header and append
header = strread(fgetl(fin),'%s','delimiter',' ');
total_dat(1,i) = header(2);
% Read data and form array
total_dat(2:1+str2num(cell2mat(header(1))),i) = strread(fgetl(fin),'%s','delimiter',' ');
end

% Open output file and write data
xlswrite([filename(1:end-3) '.xlsx'],total_dat);

fclose('all');

Somesh
2009-07-14, 14:19
Extracted data in MovAlyzeR is stored in a .EXT file. Like all MovAlyzeR files, this is an ascii-delimited file and can be readily imported into Matlab using the following command


extdata = dlmread('UserRootDir\EEE\GGG\SSS\EEEGGGSSSCCCNN.HW R');

where
EEE = Experiment ID,
GGG = Group ID,
SSS = Subject ID,
CCC = Condition ID and
NN = Trial number