%seakeeping.m %Program to produce calibrated data for seakeeping lab %author - Stephen Licht %MIT Towing Tank %April 2003 hold off; zoom off; clear all; close all; %This will prompt you to select a .i32 file to read data from, and will ask you to %select start and end points for the data. It will then will spit out four %vectors of data, which are: % 'heave_position' % 'pitch_angle' % 'surface_height' % 'time' %These variables will also be saved in a .mat file with the same %name as the .i32 file that you selected (with the extension .mat so %as to avoid writing over the raw data file. %Enter the calibration coefficients supplied by you friendly TA for the %heave and pitch sensors, as well as the wave probe calibration that you %obtained, in the appropriate place below: %---------------------------------------------------------------------- %---------------------------------------------------------------------- %Enter calibration data here heave_coefficient = 1 %cm/volt pitch_coefficient = 1 %rad/volt pitch_offset = 1 %volt wave_probe_coefficient = 1 %cm/volt wave_probe_offset = 1 %volt %---------------------------------------------------------------------- %---------------------------------------------------------------------- %You must have the file 'parsedl2.m' in your matlab path or in the %directory from which you run this code! Ignore the warning that some %later versions of Matlab generate when you run parsedl2. %open window to get data file: [filen, pathn] = uigetfile('*.i32','OPEN Lab Data File'); filestub = [pathn '' filen]; [pathstr,filename,ext,versn] = fileparts(filestub) %Load i32 format data and create array with channel 1,2,3,4 in columns: [data_raw]= parsedl2(filestub,4)'; %Apply calibration coefficient and offset for all sensors (except for drag sesnsor): heave_position = data_raw(:,2)*heave_coefficient; pitch_angle = (data_raw(:,3) + pitch_offset)*pitch_coefficient; surface_height = (data_raw(:,4)+wave_probe_offset)*wave_probe_coefficient; %Create time scale vector: dt=.005; %Sampling at 200Hz time=0:dt:(length(data_raw)-1)*dt; %Get region of interest by displaying data and having user pick %desired data start and end times: figure plot(time,heave_position); ylabel('Heave Position (cm)') xlabel('Time (s)'); title('Pick Start Point and End Point'); [a,b]=ginput(2); [a]=round(a)/dt; %Shorten all data vectors they only include the desired range: heave_position=heave_position(a(1):a(2),:); pitch_angle=pitch_angle(a(1):a(2),:); surface_height=surface_height(a(1):a(2),:); time=time(a(1):a(2)); save(filename,'heave_position','pitch_angle','surface_height','time');