Skip to content

Commit

Permalink
Added start prompt and shell script to open interface
Browse files Browse the repository at this point in the history
The shell script to open the interface is itself being opened by a .Command file created on the desktop of the Mac used to develop SedSettle.
  • Loading branch information
NWRichmond committed Sep 17, 2018
1 parent 330c807 commit 1f7295d
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 23 deletions.
Binary file modified .DS_Store
Binary file not shown.
38 changes: 16 additions & 22 deletions SettlingTubeInterface.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
%% WELCOME TO THE SETTLING TUBE INTERFACE
% SIMPLY SET THE FOLLOWING VARIABLES IN THE 'SETUP' SECTION:
% sample_short_name, dry_weight_input, minutes, sampling_interval, water_temp
% ...and press 'Run' to begin the data collection
%% CLEANUP
clear; clc;
%% SETUP
Expand All @@ -6,24 +10,16 @@
string(datetime('now','Format','d-MMM-y_HH:mm')));
dry_weight_input = 9.80; % g
minutes = 10; % number of minutes to collect data (default is 10 minutes)
sampling_interval = 0.2; % how often should the data be collected (seconds)?
water_temp = 24; % degrees C
sampling_interval = 0.1; % how often should the data be collected (seconds)?
water_temp = 23; % degrees C
settling_tube_length = 203.3; % cm
use_synthetic_data = false; % set to true to use synthetic data for testing purposes
time_collected = datetime;
%% PACKAGE DATA AS STRUCTS
SampleVars = struct('minutes',minutes,'sampling_interval',sampling_interval, ...
'dry_weight_input',dry_weight_input);
STvars = struct('water_temp',water_temp,'st_length',settling_tube_length);
%% OPTIONALLY, USE SYNTHETIC DATA
% NOTE: This code requires the MATLAB Fuzzy Logic Toolbox
if use_synthetic_data == true
[data_grainSizeResults, mass_plot, dry_weight_input] = runSyntheticData(SampleVars, STvars);
end
%% TAKE MEASUREMENTS WITH THE MASS BALANCE
if use_synthetic_data == false
[data_grainSizeResults, mass_plot, data_mass_timeseries, data_expected_kinematics] = runSettlingTube(SampleVars, STvars);
end
[data_grainSizeResults, mass_plot, data_mass_timeseries, data_expected_kinematics] = runSettlingTube(SampleVars, STvars);
%% RUN THE STATISTICS
grainStatistics(dry_weight_input, data_grainSizeResults)
folkWardStats(data_grainSizeResults, phiPercentiles(data_grainSizeResults))
Expand All @@ -33,16 +29,14 @@
phi_size_distribution = plotPhiDistribution(data_grainSizeResults);
%% SAVE RESULTS
% NOTE: This happens automatically if you are in the SedSettle directory
if use_synthetic_data == false
pwd_parts = strsplit(pwd,'/');
if strcmp(pwd_parts(end), 'SedSettle') == 1
workspaceOut = fullfile('results',sample_long_name);
else % if not in the SedSettle directory, prompt to choose a save location
msgbox('Select a directory to save the SedSettle results in.')
selpath = uigetdir(pwd,'Select save location for SedSettle results');
workspaceOut = fullfile(selpath,sample_long_name);
end
warning('off','MATLAB:Figure:FigureSavedToMATFile')
save(strcat(workspaceOut,'.mat'))
pwd_parts = strsplit(pwd,'/');
if strcmp(pwd_parts(end), 'SedSettle') == 1
workspaceOut = fullfile('results',sample_long_name);
else % if not in the SedSettle directory, prompt to choose a save location
msgbox('Select a directory to save the SedSettle results in.')
selpath = uigetdir(pwd,'Select save location for SedSettle results');
workspaceOut = fullfile(selpath,sample_long_name);
end
warning('off','MATLAB:Figure:FigureSavedToMATFile')
save(strcat(workspaceOut,'.mat'))
disp('Settling tube data collection COMPLETE')
3 changes: 3 additions & 0 deletions functions/runSyntheticData.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
function [new_mass_timeseries, figHandle, dry_weight_input] = runSyntheticData(SampleVars, STvars)
% Use artificial data instead of data collected with the settling tube.
% Requires the Fuzzy Logic Toolbox.
%
% To run from SettlingTubeInterface.m:
% [data_grainSizeResults, mass_plot, dry_weight_input] = runSyntheticData(SampleVars, STvars);
minutes = SampleVars.minutes;
sampling_interval = SampleVars.sampling_interval;
x = (0:sampling_interval:((60*minutes)-sampling_interval)); % time in seconds
Expand Down
8 changes: 7 additions & 1 deletion functions/startSounds.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ function startSounds(~, ~, firstbeeps, secondbeeps, time_between_beeps)
t1.TimerFcn = @(~,thisEvent)sound(c_tone);
t1.StopFcn = @(~,thisEvent)start(t2);

start(t1)
t0 = timer();
t0.ExecutionMode = 'singleShot';
t0.TimerFcn = @(~,thisEvent)waitfor(msgbox('Press OK to begin the Settling Tube data collection.'));
t0.StopFcn = @(~,thisEvent)start(t1);

start(t0)

end

Binary file added results/DanSand_02_10-Sep-2018_10:30.mat
Binary file not shown.
4 changes: 4 additions & 0 deletions shell/SettlingTube.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#/bin/bash
matlabroot='/Applications/MATLAB_R2018a.app/bin/'
cd $matlabroot
./matlab -r "open('SettlingTubeInterface.m')" -sd '~/Documents/GitHub/SedSettle'

0 comments on commit 1f7295d

Please sign in to comment.