Code covered by the BSD License  

Highlights from
Explore Experimental Data

image thumbnail

Explore Experimental Data

by

 

17 Mar 2012 (Updated )

The tool makes some of MATLAB's plotting and analysing functions available by a GUI

dataExpDemo2()
function Data = dataExpDemo2()
% dataExpDemo2 Creates basic demo data for guiPlotData and shows some
% functions of the data class 'dataExp'
%-------------------------------------------------------------------------%
% Usage:
%    Data = dataExpDemo2
%
% Output:
%    Data:  dataExp object (i.e. handle object)
%
% See also dataExp, dataFig, dataPlot, dataSel, guiPlotData, guiBrowseData
%
%-------------------------------------------------------------------------%
%   Copyright 2012 Alexander Klein
%   $Revision: 0.1.0 $  $Date: 2012/03/16 20:33:00 $
%-------------------------------------------------------------------------%

% perform some experiments (that creates some data) and store them in
% dataExp object
Data = dataExp;

for i=1:300
    out = singleExperiment();
    EXP = sprintf('Experiment_%.5d', i);
    % store number of experiment
    Data.addData(EXP, i);
    % add main data
    Data.addData({...
        EXP, 'time',        out.x;
        EXP, 'cleanSignal', out.y1;
        EXP, 'noisySignal', out.y2;
        EXP, 'amplitude',   out.amplitude;
        EXP, 'period',      out.period;
        EXP, 'sigma',       out.sigma});
    % link y-value to x-value
    Data.addData(EXP, 'cleanSignal', 'xNative', 'time');
    Data.addData(EXP, 'noisySignal', 'xNative', 'time');
    % set comment for experiment
    Data.setEXPComment(EXP, 'Just an example');
end
% Set name and unit for some UID(s)
Data.setUIDName({...
    'cleanSignal',          'clean signal';
    'noisySignal',          'noisy signal';
    'time',                 'time'});
Data.setUIDUnit({...
    'cleanSignal',          '-';
    'noisySignal',          '-';
    'time',                 's'});
% Rename EXP(s)
strEXPOld = Data.allEXP;
strEXPNew = strrep(strEXPOld, 'Experiment', 'experiment');
Data.renameEXP(strEXPOld, strEXPNew);
% Rename UID(s) twice
strUIDOld = Data.allUID;
strUIDNew = cellfun(@upper, strUIDOld, 'UniformOutput', false);
Data.renameUID(strUIDOld, strUIDNew);
strUIDOld = Data.allUID;
strUIDNew = cellfun(@lower, strUIDOld, 'UniformOutput', false);
Data.renameUID(strUIDOld, strUIDNew);
% Set comment for experiment
strComment = repmat({['Experiment performed on: ' datestr(now)]}, numel(strEXPNew), 1);
Data.setEXPComment(strEXPNew, strComment);
% find values where the amplitude is smaller than given value
% exp = Data.findValue('value', 'x<5',:,'amplitude');
end

function out = singleExperiment
% singleExperiment Returns a structure with some data that should be stored

amp = randi([1   10]);
per = randi([10, 20]);
sig = 0.05 + rand(1) * 0.8;
x   = linspace(0, 4*per, 1000);
y1  = amp * sin(x/per * 2 * pi);
y2  = y1 + sig .* randn(size(x));
out.x         = x;
out.y1        = y1;
out.y2        = y2;
out.amplitude = amp;
out.period    = per;
out.sigma     = sig;
end

Contact us