Home » Source Code » mocaptoolbox » mcplottimeseries.m

mcplottimeseries.m ( File view )

From:mocaptoolbox
  • By mountain 2013-11-27
  • View(s):18
  • Download(s):0
  • Point(s): 1
			function mcplottimeseries(varargin)
% Plots motion capture data as time series.
%
% syntax
% mcplottimeseries(d, marker) % for MoCap or norm data structure
% mcplottimeseries(d, marker, 'dim', dim) % specifying dimensions to be plotted
% mcplottimeseries(d, marker, 'timetype', timetype) % axis unit
% mcplottimeseries(d, marker, 'plotopt', plotopt) % combined or separate plots
% mcplottimeseries(d, marker, 'label', label) % y-axis label 
% mcplottimeseries(d, marker, 'names', names) % marker names 
% mcplottimeseries(s, segm, 'var', var) % for segm data structure
%
% input parameters
% d/s: MoCap data structure, norm data structure, or segm data structure
% marker: vector containing marker numbers or cell array containing marker names (for MoCap or norm data structure)
% segm: body segment numbers or cell array containing segment names (for segm data structure)
% dim: dimensions to be plotted (for MoCap data structure - default: 1)
% var: variable to be plotted for segment segm (for segm data structure - default: 1)
% timetype: time type used in the plot ('sec' (seconds - default) or 'frame')
% plotopt: plotting option (for MoCap or norm data structure); 'sep' (default) or 'comb':
%   sep: all time series  are plotted in separate subplots
%   comb: all time series will be plotted into the same plot using different colors)
% label: y-axis label (default: no y-axis label). X-axis label is always set, according to timetype
%   (however, for plotting neither x-axis nor y-axis labels: 'label', 0)
% names: if marker names (instead of numbers) are plotted in title and legend (0: numbers (default), 1: names)
%
% output
% Figure.
%
% examples
% mcplottimeseries(d, 2) % MoCap or norm data structure, marker 2, dim 1
% mcplottimeseries(d, {
'Head_FL','Finger_L'
}) %marker names instead of numbers (works for segments as well)
% mcplottimeseries(d, 1:3, 'dim', 1:3) % markers 1 to 3, dimensions 1 to 3
% mcplottimeseries(d, 1:3, 'dim', 3, 'timetype', 'frame') % frames as x axis unit
% mcplottimeseries(d, 5, 'dim', 1:3, 'plotopt', 'comb') % all in one plot, different colors per dim
% mcplottimeseries(d, 5, 'dim', 1:3, 'plotopt', 'comb', 'label', 'mm') % y-axis label: mm
% mcplottimeseries(d, 5, 'dim', 1:3, 'timetype', 'frame', 'label', 0) % no x- axis (and no y-axis) label
% mcplottimeseries(d, 5, 'names', 1) % marker names (instead of numbers) plotted in title and legend
% mcplottimeseries(s, [3 6 20], 'var', 'angle') % for segm data structure
% mcplottimeseries(s, 5:10, 'var', 'eucl', 'timetype', 'frame') % frames as x axis unit
% mcplottimeseries(s, [12 14], 'var', 'quat', 'dim', 2, 'plotopt', 'comb') % all in one plot, component 2
% 
% comment
%
%  Part of the Motion Capture Toolbox, Copyright 2008,
% University of Jyvaskyla, Finland


% New syntax [BB 20110131]:

% for backwards compatibility for users, who haven't adapted their syntax yet
if nargin>2
    if (strcmp(varargin{
3
},'dim') + strcmp(varargin{
3
},'var') + strcmp(varargin{
3
},'timetype') + ...
            strcmp(varargin{
3
},'plotopt') + strcmp(varargin{
3
},'label') + strcmp(varargin{
3
},'names')) == 0
        disp([10, 'Warning: You are using an old version of mcplottimeseries. Please consider adapting your syntax to the new version.'])
        disp(['For more information, check the Mocap Toolbox manual.', 10])
        mcplottimeseries_dep(varargin{
1:end
});
        return
    end
end
        
d=varargin{
1
};
marker=varargin{
2
};

dim=[];
var=[];
timetype=[];
plotopt=[];
label=[];
names=[];

for k=3:2:length(varargin)
    if strcmp(varargin{
k
}, 'dim')
        dim=varargin{
k+1
};
    elseif strcmp(varargin{
k
}, 'var')
        var=varargin{
k+1
};
    elseif strcmp(varargin{
k
}, 'timetype')
        timetype=varargin{
k+1
};
    elseif strcmp(varargin{
k
}, 'plotopt')
        plotopt=varargin{
k+1
};
    elseif strcmp(varargin{
k
}, 'label')
        label=varargin{
k+1
};
    elseif strcmp(varargin{
k
}, 'names')
        names=varargin{
k+1
};
    else
        str=sprintf('Input argument %s unknown.', varargin{
k
});
        disp([10, str, 10])
    end
end


%set default values and check for incorrect spelling

if isempty(dim)
    dim=1;
end

if strcmp(d.type, 'MoCap data') || strcmp(d.type, 'norm data')
    if max(dim)>size(d.data,2)/d.nMarkers
        disp([10, 'Dimension (dim) value exceeds existing dimensions (no plot created).', 10])
        return
    end
end

if strcmp(d.type, 'segm data')
    if isempty(var)
        disp([10, 'Please specify segment variable (var) to be plotted (no plot created).', 10])
        return
    end
    if strcmp(var,'angle')
        if max(dim)>1
            disp([10, 'Dimension (dim) value exceeds existing dimensions (no plot created).', 10])
            return
        end
    elseif strcmp(var,'eucl')
        if max(dim)>3
            disp([10, 'Dimension (dim) value exceeds existing dimensions (no plot created).', 10])
            return
        end
    elseif strcmp(var,'quat')
        if max(dim)>4
            disp([10, 'Component (dim) value exceeds existing components (no plot created).', 10])
            return
        end
    end
end

if isempty(timetype)
    timetype='sec';
end
if strcmp(timetype,'sec') || strcmp(timetype,'frame')
else
    timetype='sec';
    disp([10, 'Incorrect spelling of timetype input. Value set to "sec".', 10])
end

if isempty(plotopt)
    plotopt='sep';
end
if strcmp(plotopt,'sep') || strcmp(plotopt,'comb')
else
    plotopt='sep';
    disp([10, 'Incorrect spelling of plotopt input. Value set to "sep".', 10])
end

if isempty(names)
    names=0;
end
if names>1
    disp([10, 'Names input bigger than 1 or in incorrect format, value is set to 1.', 10])
    names=1;
end

if strcmp(d.type, 'MoCap data') || strcmp(d.type, 'norm data') || strcmp(d.type, 'segm data')
else
    disp([10, 'The first input argument should be a variable with MoCap, norm, or segm data structure (no plot created).', 10]);
    return
end

if nargin<2
    disp([10, 'Please specify data and/or markers (or segments) to be plotted (no plot created).', 10])
    return
end

if iscell(marker)
    marker=name2number(d,marker);
    if isempty(marker) %no plot created if all markers that are given are misspelled
        return
    end
end

if ischar(marker) %if string is entered
    disp([10, 'Marker number has to be either numbers or cell array with marker names (no plot created).', 10]);
    return
end
if max(marker)>d.nMarkers
    disp([10, 'Marker number out of range (no plot created).', 10]);
    return
end


p1=marker;
p2=dim;

set(0,'DefaultTextInterpreter','none') %for underscores (and such) in marker names

colors={
'blue', 'green', 'red', 'cyan', 'magenta', 'yellow', 'black'
};

if isfield(d,'type')
    t = (1:d.nFrames)';%-1 taken away as it caused time series to start at 0... [BB 20110301]
    if strcmp(timetype,'sec') 
        t = t/d.freq; 
    end
    if strcmp(d.type, 'MoCap data')
        figure
        al=1;%amount of lines - for 'comb' plotting
        for k=1:length(p1)
            for m=1:length(p2)
                if strcmp(plotopt, 'sep')
                    subplot(length(p1), length(p2), length(p2)*(k-1)+m)
                    pl=plot(t, d.data(:,3*p1(k)-3+p2(m)));
                    axis([min(t) max(t) -Inf Inf])
                    if names==0
                        title(['Marker ' num2str(p1(k)) ', dim. ' num2str(p2(m))])
                    elseif names==1
                        title(['Marker ' char(d.markerName{
p1(k)
}) ', dim. ' num2str(p2(m))])
                    end
                else
                    pl=plot(t, d.data(:,3*p1(k)-3+p2(m)));
                    axis([min(t) max(t) -Inf Inf])
                    set(pl,'color',colors{
mod(al-1,7)+1
}) %al has 4 colors, should start over with blue after 7 lines
                    if names==0
                        title(['Marker [' num2str(p1) '], dim. [' num2str(p2) ']'])
                        st{
al
} = ['M. ' num2str(p1(k)) ', dim. ' num2str(p2(m))];
                    elseif names==1
                        title(['Marker [' num2str(p1) '], dim. [' num2str(p2) ']'])
                        st{
al
} = ['M. ' char(d.markerName{
p1(k)
}) ', dim. ' num2str(p2(m))];
                    end 
                    al=al+1;
                    hold on
                end
                if ~isscalar(label) %if label is [] or string, then plot labels
                    if strcmp('sec',timetype)
                        xlabel('seconds')
                    else xlabel('frames')
                    end
                    if ~isempty(label)
                        ylabel(label)
                    end
                end
            end
        end
        if strcmp(plotopt, 'comb') %plot legend
            leg=legend(st, 'Location', 'EastOutside'); 
        end 
    elseif strcmp(d.type, 'norm data')
        figure
        al=1;%amount of lines - for 'comb' plotting
        plot(t, d.data(:,p1));
        for k=1:length(p1)
            for m=1%:length(p2)
                if strcmp(plotopt, 'sep') 
                    subplot(length(p1), 1, k)
                    plot(t, d.data(:,p1(k)))
                    axis([min(t) max(t) -Inf Inf])
                    if names==0
                        title(['Marker ' num2str(p1(k)) ', norm data'])
                    elseif names==1
                        title(['Marker ' char(d.markerName{
p1(k)
}) ', norm data'])
                    end
                else
                    pl=plot(t, d.data(:,p1(k))); %FIXBB110102: 'comb' also for norm data
                    axis([min(t) max(t) -Inf Inf])
                    set(pl,'color',colors{
mod(al-1,7)+1
}) %al has 4 colors, should start over with blue after 7 lines
                    
%                     title(['Marker [' num2str(p1) '], norm data'])
                    if names==0
                        title(['Marker [' num2str(p1) '], norm data'])
                        st{
al
} = ['M. ' num2str(p1(k))];
                    elseif names==1
                        title(['Marker [' num2str(p1) '], norm data'])
                        st{
al
} = ['M. ' char(d.markerName{
p1(k)
})];
                    end

                    al=al+1;
                    hold on
                end
                if ~isscalar(label) %if label is [] or strin
...
...
(Not finished, please download and read the complete file)
			
...
Expand> <Close

Want complete source code? Download it here

Point(s): 1

Download
0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
01.97 kB
License.txt15.84 kB2013-02-12 03:05
01.97 kB
01.97 kB
._License.txt313.00 B2013-02-12 03:05
MCT_manual_v1.4.pdf1.92 MB2013-02-12 04:00
._MCT_manual_v1.4.pdf82.00 B2013-02-12 04:00
01.97 kB
.DS_Store15.00 kB2013-02-11 04:26
01.97 kB
._.DS_Store193.00 B2013-02-11 04:26
contents.m3.85 kB2013-02-12 03:20
._contents.m171.00 B2013-02-12 03:20
<Icon^M>0.00 B2008-03-04 19:13
._Icon^M43.58 kB2008-03-04 19:13
mc2frontal.m2.02 kB2011-10-18 09:23
._mc2frontal.m82.00 B2011-10-18 09:23
mcanimate.m1.33 kB2011-10-18 09:04
._mcanimate.m266.00 B2011-10-18 09:04
mcbandpass.m3.49 kB2011-10-18 09:01
._mcbandpass.m82.00 B2011-10-18 09:01
mcboundrect.m1.74 kB2011-10-19 08:03
._mcboundrect.m82.00 B2011-10-19 08:03
mcc3d2tsv.m2.70 kB2012-04-16 05:29
._mcc3d2tsv.m82.00 B2012-04-16 05:29
mccenter.m804.00 B2011-10-17 11:55
._mccenter.m82.00 B2011-10-17 11:55
mcconcatenate.m2.70 kB2013-02-12 03:01
._mcconcatenate.m82.00 B2013-02-12 03:01
mccreateconnmatrix.m1.89 kB2011-10-19 09:00
._mccreateconnmatrix.m82.00 B2011-10-19 09:00
mccumdist.m1.17 kB2011-10-19 08:54
._mccumdist.m82.00 B2011-10-19 08:54
mccut.m698.00 B2011-10-18 08:26
._mccut.m82.00 B2011-10-18 08:26
mcdecompose.m1.58 kB2011-10-18 08:20
._mcdecompose.m82.00 B2011-10-18 08:20
mcdemo.m1.82 kB2011-10-14 09:29
._mcdemo.m82.00 B2011-10-14 09:29
mcdemo1.m4.13 kB2012-04-12 05:37
._mcdemo1.m82.00 B2012-04-12 05:37
mcdemo10.m2.27 kB2013-01-29 07:56
._mcdemo10.m82.00 B2013-01-29 07:56
mcdemo11.m1.87 kB2012-04-12 08:04
._mcdemo11.m167.00 B2012-04-12 08:04
mcdemo2.m2.27 kB2008-05-21 00:26
._mcdemo2.m193.00 B2008-05-21 00:26
mcdemo3.m3.46 kB2013-02-11 13:20
._mcdemo3.m82.00 B2013-02-11 13:20
mcdemo4.m3.09 kB2008-05-27 15:53
._mcdemo4.m193.00 B2008-05-27 15:53
mcdemo5.m4.13 kB2013-01-29 07:45
._mcdemo5.m82.00 B2013-01-29 07:45
mcdemo6.m1.28 kB2008-05-21 00:20
._mcdemo6.m82.00 B2008-05-21 00:20
mcdemo7.m1.38 kB2008-05-21 00:20
._mcdemo7.m82.00 B2008-05-21 00:20
mcdemo8.m2.17 kB2010-05-21 10:42
._mcdemo8.m82.00 B2010-05-21 10:42
mcdemo9.m2.86 kB2013-01-29 07:56
._mcdemo9.m82.00 B2013-01-29 07:56
mcdemodata.mat1.27 MB2012-04-16 04:59
._mcdemodata.mat82.00 B2012-04-16 04:59
mceigenmovement.m1.66 kB2011-10-18 08:18
._mceigenmovement.m82.00 B2011-10-18 08:18
mcfillgaps.m5.57 kB2011-10-18 08:15
._mcfillgaps.m167.00 B2011-10-18 08:15
mcfilteremg.m1.32 kB2011-10-18 09:43
._mcfilteremg.m82.00 B2011-10-18 09:43
mcgetmarker.m1.29 kB2013-02-11 04:25
._mcgetmarker.m82.00 B2013-02-11 04:25
mcgetmarkername.m582.00 B2011-10-17 11:43
._mcgetmarkername.m82.00 B2011-10-17 11:43
mcgetsegmpar.m2.73 kB2011-10-18 08:00
._mcgetsegmpar.m82.00 B2011-10-18 08:00
mchilbert.m1.01 kB2011-10-17 11:48
._mchilbert.m82.00 B2011-10-17 11:48
mchilberthuang.m1.43 kB2011-10-18 07:57
._mchilberthuang.m82.00 B2011-10-18 07:57
mcicaproj.m1.59 kB2011-10-18 07:54
._mcicaproj.m82.00 B2011-10-18 07:54
mcinitanimpar.m2.73 kB2011-11-01 11:54
._mcinitanimpar.m266.00 B2011-11-01 11:54
mcinitj2spar.m675.00 B2011-10-17 10:24
._mcinitj2spar.m82.00 B2011-10-17 10:24
mcinitm2jpar.m643.00 B2011-10-17 10:24
._mcinitm2jpar.m82.00 B2011-10-17 10:24
mcinitstruct.m3.75 kB2011-10-18 09:28
._mcinitstruct.m82.00 B2011-10-18 09:28
mcj2s.m2.20 kB2011-10-17 12:28
._mcj2s.m82.00 B2011-10-17 12:28
mckinenergy.m2.08 kB2011-12-12 04:04
._mckinenergy.m82.00 B2011-12-12 04:04
mckurtosis.m791.00 B2011-10-17 12:24
._mckurtosis.m82.00 B2011-10-17 12:24
mcm2j.m1.08 kB2011-10-17 12:28
._mcm2j.m82.00 B2011-10-17 12:28
mcmakedemoparams.m2.39 kB2008-05-13 14:29
._mcmakedemoparams.m82.00 B2008-05-13 14:29
mcmarkerdist.m763.00 B2011-10-17 12:29
._mcmarkerdist.m82.00 B2011-10-17 12:29
mcmean.m623.00 B2011-10-19 08:52
._mcmean.m82.00 B2011-10-19 08:52
mcmerge.m14.48 kB2013-02-12 02:57
._mcmerge.m82.00 B2013-02-12 02:57
mcmissing.m936.00 B2011-10-18 07:41
._mcmissing.m82.00 B2011-10-18 07:41
mcmocapgram.m1.89 kB2013-02-01 16:12
._mcmocapgram.m338.00 B2013-02-01 16:12
mcnorm.m830.00 B2011-10-18 07:41
._mcnorm.m82.00 B2011-10-18 07:41
mcpcaproj.m2.76 kB2013-02-12 03:16
._mcpcaproj.m82.00 B2013-02-12 03:16
mcperiod.m3.21 kB2013-02-12 03:16
._mcperiod.m82.00 B2013-02-12 03:16
mcplotframe.m13.90 kB2013-02-10 11:58
._mcplotframe.m82.00 B2013-02-10 11:58
mcplotphaseplane.m3.38 kB2011-10-18 07:26
._mcplotphaseplane.m82.00 B2011-10-18 07:26
mcplottimeseries.m17.26 kB2013-01-29 08:36
._mcplottimeseries.m82.00 B2013-01-29 08:36
mcplottimeseries_dep.m6.72 kB2013-01-29 08:35
._mcplottimeseries_dep.m82.00 B2013-01-29 08:35
mcpotenergy.m1.69 kB2011-10-18 03:23
._mcpotenergy.m82.00 B2011-10-18 03:23
mcread.m2.44 kB2012-04-13 10:31
._mcread.m312.00 B2012-04-13 10:31
mcreademg.m1.71 kB2011-10-18 03:17
._mcreademg.m331.00 B2011-10-18 03:17
mcreorderdims.m678.00 B2011-10-18 03:04
._mcreorderdims.m82.00 B2011-10-18 03:04
mcresample.m951.00 B2011-10-17 13:01
._mcresample.m82.00 B2011-10-17 13:01
mcrotate.m2.50 kB2011-10-18 03:36
._mcrotate.m330.00 B2011-10-18 03:36
mcs2j.m1.41 kB2011-10-17 13:08
._mcs2j.m82.00 B2011-10-17 13:08
mcs2posture.m541.00 B2011-10-17 13:08
._mcs2posture.m82.00 B2011-10-17 13:08
mcsegmangle.m725.00 B2011-10-17 13:08
._mcsegmangle.m82.00 B2011-10-17 13:08
mcsethares.m3.93 kB2011-10-18 02:59
._mcsethares.m82.00 B2011-10-18 02:59
mcsetmarker.m3.03 kB2013-02-10 11:58
._mcsetmarker.m82.00 B2013-02-10 11:58
mcsimmat.m952.00 B2011-10-18 03:35
._mcsimmat.m82.00 B2011-10-18 03:35
mcskewness.m728.00 B2011-10-19 08:55
._mcskewness.m82.00 B2011-10-19 08:55
mcsmoothen.m3.43 kB2011-10-17 13:17
._mcsmoothen.m82.00 B2011-10-17 13:17
mcspectrum.m1.83 kB2011-10-18 02:53
._mcspectrum.m266.00 B2011-10-18 02:53
mcstatmoments.m707.00 B2011-10-19 08:56
._mcstatmoments.m82.00 B2011-10-19 08:56
mcstd.m649.00 B2011-10-19 08:55
._mcstd.m82.00 B2011-10-19 08:55
mctimeder.m6.67 kB2012-04-12 08:39
._mctimeder.m82.00 B2012-04-12 08:39
mctimeintegr.m1.59 kB2011-10-18 03:37
._mctimeintegr.m82.00 B2011-10-18 03:37
mctranslate.m761.00 B2011-10-17 13:24
._mctranslate.m82.00 B2011-10-17 13:24
mctrim.m2.00 kB2011-10-19 04:44
._mctrim.m82.00 B2011-10-19 04:44
mcvar.m629.00 B2011-10-19 08:56
._mcvar.m82.00 B2011-10-19 08:56
mcvect2grid.m1.38 kB2011-10-19 08:09
._mcvect2grid.m82.00 B2011-10-19 08:09
mcwindow.m3.32 kB2011-10-18 03:37
._mcwindow.m82.00 B2011-10-18 03:37
mcwritetsv.m2.27 kB2012-04-16 05:29
._mcwritetsv.m376.00 B2012-04-16 05:29
01.97 kB
.DS_Store6.00 kB2012-04-12 09:26
01.97 kB
._.DS_Store193.00 B2012-04-12 09:26
dir2quat.m568.00 B2008-01-17 18:16
._dir2quat.m193.00 B2008-01-17 18:16
initemptymc.mat127.62 kB2009-11-29 17:45
makecolumn.m257.00 B2007-09-11 13:58
mcica.m1.04 kB2010-05-07 03:59
._mcica.m193.00 B2010-05-07 03:59
mcpca.m829.00 B2008-12-10 13:09
._mcpca.m82.00 B2008-12-10 13:09
mcreadc3d.m1.21 kB2011-09-07 06:28
._mcreadc3d.m82.00 B2011-09-07 06:28
mcreadmat.m2.00 kB2011-09-07 06:26
._mcreadmat.m312.00 B2011-09-07 06:26
mcreadtsv.m3.50 kB2012-04-13 05:38
._mcreadtsv.m82.00 B2012-04-13 05:38
mcreadwii.m1.02 kB2011-09-07 06:26
._mcreadwii.m171.00 B2011-09-07 06:26
mypca.m507.00 B2008-10-21 15:46
._mypca.m82.00 B2008-10-21 15:46
qinv.m106.00 B2008-01-17 18:02
._qinv.m193.00 B2008-01-17 18:02
quatrot.m618.00 B2008-04-18 18:29
._quatrot.m193.00 B2008-04-18 18:29
readc3d.m12.15 kB2013-01-29 15:11
._readc3d.m341.00 B2013-01-29 15:11
readC3dIDL.m14.27 kB2009-11-30 03:02
smoothderiv.m390.00 B2006-05-21 13:26
._smoothderiv.m82.00 B2006-05-21 13:26
validfield.m464.00 B2007-04-30 11:04
._private193.00 B2013-01-31 03:26
._mocaptoolbox193.00 B2013-02-12 03:16
releasenotes_v1.4.txt5.74 kB2013-02-12 03:10
._releasenotes_v1.4.txt171.00 B2013-02-12 03:10
...
Sponsored links

mcplottimeseries.m (3.10 MB)

Need 1 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D