-
Notifications
You must be signed in to change notification settings - Fork 0
/
mcarrayPlotTimeseries.m
674 lines (586 loc) · 26.2 KB
/
mcarrayPlotTimeseries.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
function mcarrayPlotTimeseries(varargin)
%
% Plotting all entries in the array.
% Only suitable for MoCap Data or Norm Data types.
% Based on mcplottimeseries from Mocap Toolbox v1.5
% Adapted by Kristian Nymoen, RITMO/University of Oslo, 2019
%
%
% syntax
% mcarrayPlotTimeseries(d, marker) % for MoCap or norm data structure
% mcarrayPlotTimeseries(d, marker, 'dim', dim) % specifying dimensions to be plotted
% mcarrayPlotTimeseries(d, marker, 'timetype', timetype) % axis unit
% mcarrayPlotTimeseries(d, marker, 'plotopt', plotopt) % combined or separate plots
% mcarrayPlotTimeseries(d, marker, 'label', label) % y-axis label
% mcarrayPlotTimeseries(d, marker, 'names', names) % marker names
% mcarrayPlotTimeseries(s, segm, 'var', var) % for segm data structure
%
% input parameters
% d/s: MoCap data struct array, norm data struct array, or segm data struct array
% 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)
% plotMean: plot (overlay) the mean value across the struct array (0 or 1)
% plotStd: plot (overlay) the standard deviation across the struct array (0 or 1)
% showLines: show the individual lines – set to 0 if you want to only display the mean/std curves (0 or 1)
%
%
% output
% Figure.
%
% examples
% mcarrayPlotTimeseries(d, 2) % MoCap or norm data structure, marker 2, dim 1
% mcarrayPlotTimeseries(d, {'Head_FL','Finger_L'}) %marker names instead of numbers (works for segments as well)
% mcarrayPlotTimeseries(d, 1:3, 'dim', 1:3) % markers 1 to 3, dimensions 1 to 3
% mcarrayPlotTimeseries(d, 1:3, 'dim', 3, 'timetype', 'frame') % frames as x axis unit
% mcarrayPlotTimeseries(d, 5, 'dim', 1:3, 'plotopt', 'comb') % all in one plot, different colors per dim
% mcarrayPlotTimeseries(d, 5, 'dim', 1:3, 'plotopt', 'comb', 'label', 'mm') % y-axis label: mm
% mcarrayPlotTimeseries(d, 5, 'dim', 1:3, 'timetype', 'frame', 'label', 0) % no x- axis (and no y-axis) label
% mcarrayPlotTimeseries(d, 5, 'names', 1) % marker names (instead of numbers) plotted in title and legend
% mcarrayPlotTimeseries(s, [3 6 20], 'var', 'angle') % for segm data structure
% mcarrayPlotTimeseries(s, 5:10, 'var', 'eucl', 'timetype', 'frame') % frames as x axis unit
% mcarrayPlotTimeseries(s, [12 14], 'var', 'quat', 'dim', 2, 'plotopt', 'comb') % all in one plot, component 2
%
%
%
d=varargin{1};
marker=varargin{2};
dim=[];
var=[];
timetype=[];
plotopt='comb';
label=[];
names=[];
plotMean=0;
plotStd=0;
showLines=1;
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};
elseif strcmpi(varargin{k}, 'plotMean')
plotMean=varargin{k+1};
elseif strcmpi(varargin{k}, 'plotStd')
plotStd=varargin{k+1};
elseif strcmpi(varargin{k}, 'showLines')
showLines=varargin{k+1};
else
str=sprintf('Input argument %s unknown.', varargin{k});
disp([10, str, 10])
% [y,fs] = audioread('mcsound.wav');
% sound(y,fs);
% return
end
end
if plotStd
plotMean = 1;
end
if ~plotMean
showLines = 1;
end
%set default values and check for incorrect spelling
if isempty(dim)
dim=1;
end
if strcmp(d(1).type, 'MoCap data') || strcmp(d(1).type, 'norm data')
if max(dim)>size(d(1).data,2)/d(1).nMarkers
disp([10, 'Dimension (dim) value exceeds existing dimensions (no plot created).', 10])
[y,fs] = audioread('mcsound.wav');
sound(y,fs);
return
end
end
if strcmp(d(1).type, 'segm data')
if isempty(var)
disp([10, 'Please specify segment variable (var) to be plotted (no plot created).', 10])
[y,fs] = audioread('mcsound.wav');
sound(y,fs);
return
end
if strcmp(var,'angle')
if max(dim)>1
disp([10, 'Dimension (dim) value exceeds existing dimensions (no plot created).', 10])
[y,fs] = audioread('mcsound.wav');
sound(y,fs);
return
end
elseif strcmp(var,'eucl')
if max(dim)>3
disp([10, 'Dimension (dim) value exceeds existing dimensions (no plot created).', 10])
[y,fs] = audioread('mcsound.wav');
sound(y,fs);
return
end
elseif strcmp(var,'quat')
if max(dim)>4
disp([10, 'Component (dim) value exceeds existing components (no plot created).', 10])
[y,fs] = audioread('mcsound.wav');
sound(y,fs);
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(1).type, 'MoCap data') || strcmp(d(1).type, 'norm data') || strcmp(d(1).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]);
[y,fs] = audioread('mcsound.wav');
sound(y,fs);
return
end
if nargin<2
disp([10, 'Please specify data and/or markers (or segments) to be plotted (no plot created).', 10])
[y,fs] = audioread('mcsound.wav');
sound(y,fs);
return
end
if iscell(marker)
marker=name2number(d(1),marker);
if isempty(marker) %no plot created if all markers that are given are misspelled
disp([10, 'Please specify data and/or markers (or segments) to be plotted (no plot created).', 10])
[y,fs] = audioread('mcsound.wav');
sound(y,fs);
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]);
[y,fs] = audioread('mcsound.wav');
sound(y,fs);
return
end
if max(marker)>d(1).nMarkers
disp([10, 'Marker number out of range (no plot created).', 10]);
[y,fs] = audioread('mcsound.wav');
sound(y,fs);
return
end
p1=marker;
p2=dim;
tmax = [];
set(0,'DefaultTextInterpreter','none') %for underscores (and such) in marker names
colors={[0 0.4470 0.7410],[0.8500 0.3250 0.0980],[0.9290 0.6940 0.1250],[0.4940 0.1840 0.5560],[0.4660 0.6740 0.1880],[0.3010 0.7450 0.9330],[0.6350 0.0780 0.1840]};
if plotMean %lighter colors when showing mean curves
colors2 = colors;
colors = cellfun(@(x) x*.3+.7,colors,'UniformOutput',false);
end
%figure
if isfield(d(1),'type')
for di = 1:length(d)
t = (1:d(di).nFrames)';%-1 taken away as it caused time series to start at 0... [BB 20110301]
if strcmp(timetype,'sec')
t = (t-1)/d(di).freq;
end
tmax = max([t; tmax]);
if strcmp(d(di).type, 'MoCap data')
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),
hold on
if showLines
pl=plot(t, d(di).data(:,3*p1(k)-3+p2(m)));
set(pl,'color',colors{mod(al-1,length(colors))+1}) %al has 7 colors, should start over with blue after 7 lines
end
axis([min(t) tmax -Inf Inf])
if names==0
title(['Marker ' num2str(p1(k)) ', dim. ' num2str(p2(m))])
elseif names==1
title(['Marker ' char(d(di).markerName{p1(k)}) ', dim. ' num2str(p2(m))])
end
else
hold on
if showLines
pl=plot(t, d(di).data(:,3*p1(k)-3+p2(m)));
set(pl,'color',colors{mod(al-1,length(colors))+1}) %al has 7 colors, should start over with blue after 7 lines
if names==0
st{al} = ['M. ' num2str(p1(k)) ', dim. ' num2str(p2(m))];
elseif names==1
st{al} = ['M. ' char(d(di).markerName{p1(k)}) ', dim. ' num2str(p2(m))];
end
al=al+1;
end
if names==0
title(['Marker [' num2str(p1) '], dim. [' num2str(p2) ']'])
elseif names==1
title(['Marker [' num2str(p1) '], dim. [' num2str(p2) ']'])
end
axis([min(t) tmax -Inf Inf])
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 showLines && strcmp(plotopt, 'comb') %plot legend
leg=legend(st, 'Location', 'EastOutside');
end
elseif strcmp(d(di).type, 'norm data')
al=1;%amount of lines - for 'comb' plotting
%plot(t, d(di).data(:,p1));
for k=1:length(p1)
for m=1%:length(p2)
if strcmp(plotopt, 'sep')
subplot(length(p1), 1, k),
hold on
if showLines
pl = plot(t, d(di).data(:,p1(k)));
set(pl,'color',colors{mod(al-1,length(colors))+1}) %al has 4 colors, should start over with blue after 7 lines
end
axis([min(t) tmax -Inf Inf])
if names==0
title(['Marker ' num2str(p1(k)) ', norm data'])
elseif names==1
title(['Marker ' char(d(di).markerName{p1(k)}) ', norm data'])
end
else
hold on
if showLines
pl=plot(t, d(di).data(:,p1(k))); %FIXBB110102: 'comb' also for norm data
axis([min(t) tmax -Inf Inf])
set(pl,'color',colors{mod(al-1,length(colors))+1}) %al has 4 colors, should start over with blue after 7 lines
% title(['Marker [' num2str(p1) '], norm data'])
if names==0
st{al} = ['M. ' num2str(p1(k))];
elseif names==1
st{al} = ['M. ' char(d(di).markerName{p1(k)})];
end
al=al+1;
end
if names==0
title(['Marker [' num2str(p1) '], norm data'])
elseif names==1
title(['Marker [' num2str(p1) '], norm data'])
end
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 showLines && strcmp(plotopt, 'comb') %plot legend
legend(st, 'Location', 'EastOutside');
end
elseif strcmp(d(di).type, 'segm data')
tmp=[];
al=1;%amount of lines - for 'comb' plotting
for k=1:length(p1)
tmp = getfield(d(di).segm(p1(k)),var);
if ~isempty(tmp)
if strcmp(var, 'angle')
if strcmp(plotopt, 'sep')
% k
subplot(length(p1),1,k),
hold on
pl = plot(t, tmp);
set(pl,'color',colors{mod(al-1,length(colors))+1}) %al has 4 colors, should start over with blue after 7 lines
axis([min(t) tmax -Inf Inf])
if names==0
title(['Segm. ' num2str(p1(k)) ' - angle'])
elseif names==1
title(['Segm. ' char(d(di).segmentName{p1(k)}) ' - angle'])
end
else
hold on
pl=plot(t, tmp); %FIXBB201202010: 'comb' also for segm data
axis([min(t) tmax -Inf Inf])
set(pl,'color',colors{mod(al-1,length(colors))+1}) %al has 4 colors, should start over with blue after 7 lines
if names==0
title(['Segm. [' num2str(p1) '] - angle'])
st{al} = ['Segm. ' num2str(p1(k))];
elseif names==1
title(['Segm. [' num2str(p1) '] - angle'])
st{al} = ['Segm. ' char(d(di).segmentName{p1(k)})];
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
elseif strcmp(var, 'eucl')
for m=1:length(p2)
if strcmp(plotopt, 'sep')
subplot(length(p1), length(p2), length(p2)*(k-1)+m),
hold on
pl = plot(t, tmp(:,p2(m)));
set(pl,'color',colors{mod(al-1,length(colors))+1}) %al has 4 colors, should start over with blue after 7 lines
if names==0
title(['Segm. ' num2str(p1(k)) ', dim. ' num2str(p2(m)) ' - eucl']);
elseif names==1
title(['Segm. ' char(d(di).segmentName{p1(k)}) ', dim. ' num2str(p2(m)) ' - eucl'])
end
axis([min(t) tmax -Inf Inf])
else
hold on
pl=plot(t, tmp(:,p2(m))); %FIXBB201202010: 'comb' also for segm data
axis([min(t) tmax -Inf Inf])
set(pl,'color',colors{mod(al-1,length(colors))+1}) %al has 4 colors, should start over with blue after 7 lines
if names==0
title(['Segm. [' num2str(p1) '], dim. [' num2str(p2) '] - eucl'])
st{al} = ['Segm. ' num2str(p1(k)) ', dim. ' num2str(p2(m)) ];
elseif names==1
title(['Segm. [' num2str(p1) '], dim. [' num2str(p2) '] - eucl'])
st{al} = ['Segm. ' char(d(di).segmentName{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
elseif strcmp(var, 'quat')
for m=1:length(p2)
if strcmp(plotopt, 'sep')
subplot(length(p1), length(p2), length(p2)*(k-1)+m),
hold on
plot(t, tmp(:,p2(m)))
if names==0
title(['Segm. ' num2str(p1(k)) ', comp. ' num2str(p2(m)) ' - quat']);
elseif names==1
title(['Segm. ' char(d(di).segmentName{p1(k)}) ', comp. ' num2str(p2(m)) ' - quat'])
end
axis([min(t) tmax -Inf Inf])
else
hold on
pl=plot(t, tmp(:,p2(m))); %FIXBB201202010: 'comb' also for segm data
axis([min(t) tmax -Inf Inf])
set(pl,'color',colors{mod(al-1,length(colors))+1}) %al has 4 colors, should start over with blue after 7 lines
if names==0
title(['Segm. [' num2str(p1) '], comp. [' num2str(p2) '] - quat'])
st{al} = ['Segm. ' num2str(p1(k)) ', comp. ' num2str(p2(m)) ];
elseif names==1
title(['Segm. [' num2str(p1) '], comp. [' num2str(p2) '] - quat'])
st{al} = ['Segm. ' char(d(di).segmentName{p1(k)}) ', comp. ' 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
else
disp([10, 'No data to be plotted.', 10])
end
end
end
if showLines && strcmp(plotopt, 'comb') %plot legend
legend(st, 'Location', 'EastOutside');
end
end
if plotMean
t = (1:min([d.nFrames]))';%-1 taken away as it caused time series to start at 0... [BB 20110301]
if strcmp(timetype,'sec')
t = (t-1)/d(1).freq;
end
if ~showLines
tmax = max(t);
end
dmean = mcarrayMean(d);
if plotStd
al=1;
if strcmp(d(1).type, 'MoCap data')
dstd = mcarrayStd(d);
for k=1:length(p1)
for m=1:length(p2)
if strcmp(plotopt, 'sep')
subplot(length(p1), length(p2), length(p2)*(k-1)+m)
%pl1 = plot(t, dmean.data(:,3*p1(k)-3+p2(m))-dstd.data(:,3*p1(k)-3+p2(m)),'k','HandleVisibility','off');
%pl2 = plot(t, dmean.data(:,3*p1(k)-3+p2(m))+dstd.data(:,3*p1(k)-3+p2(m)),'k','HandleVisibility','off');
patch([t;flip(t)],[dmean.data(:,3*p1(k)-3+p2(m))-dstd.data(:,3*p1(k)-3+p2(m));flip(dmean.data(:,3*p1(k)-3+p2(m))+dstd.data(:,3*p1(k)-3+p2(m)))],[.1 .1 .1],'FaceAlpha',0.2)
%set(pl1,'color',colors2{mod(al-1,length(colors))+1}) %al has 7 colors, should start over with blue after 7 lines
%set(pl2,'color',colors2{mod(al-1,length(colors))+1}) %al has 7 colors, should start over with blue after 7 lines
else
%pl1 = plot(t, dmean.data(:,3*p1(k)-3+p2(m))-dstd.data(:,3*p1(k)-3+p2(m)),'HandleVisibility','off');
%pl2 = plot(t, dmean.data(:,3*p1(k)-3+p2(m))+dstd.data(:,3*p1(k)-3+p2(m)),'HandleVisibility','off');
patch([t;flip(t)],[dmean.data(:,3*p1(k)-3+p2(m))-dstd.data(:,3*p1(k)-3+p2(m));flip(dmean.data(:,3*p1(k)-3+p2(m))+dstd.data(:,3*p1(k)-3+p2(m)))],colors2{mod(al-1,length(colors))+1},'FaceAlpha',0.3)
%set(pl1,'color',colors2{mod(al-1,length(colors))+1}) %al has 7 colors, should start over with blue after 7 lines
%set(pl2,'color',colors2{mod(al-1,length(colors))+1}) %al has 7 colors, should start over with blue after 7 lines
al=al+1;
hold on
end
end
end
elseif strcmp(d(1).type, 'norm data')
dstd = mcarrayStd(d);
al=1;%amount of lines - for 'comb' plotting
%plot(t, dmean.data(:,p1),'k','LineWidth',2);
for k=1:length(p1)
for m=1%:length(p2)
if strcmp(plotopt, 'sep')
subplot(length(p1), 1, k)
% plot(t, dmean.data(:,p1(k))-dstd.data(:,p1(k)),'k','HandleVisibility','off');
% plot(t, dmean.data(:,p1(k))+dstd.data(:,p1(k)),'k','HandleVisibility','off');
% h = area(,,dstd.data(:,p1(k)),dstd.data(:,p1(k))],min(dmean.data(:,p1(k))-dstd.data(:,p1(k))));%
patch([t;flip(t)],[dmean.data(:,p1(k))-dstd.data(:,p1(k));flip(dmean.data(:,p1(k))+dstd.data(:,p1(k)))],[.1 .1 .1],'FaceAlpha',0.2)
axis([min(t) tmax -Inf Inf])
else
patch([t;flip(t)],[dmean.data(:,p1(k))-dstd.data(:,p1(k));flip(dmean.data(:,p1(k))+dstd.data(:,p1(k)))],colors2{mod(al-1,length(colors))+1},'FaceAlpha',0.3)
axis([min(t) tmax -Inf Inf])
al=al+1;
hold on
end
end
end
elseif strcmp(d(1).type, 'segm data')
disp('plotting of array SD not implemented for segment data')
end
end %of if plotstd
al=1;
if strcmp(d(1).type, 'MoCap data')
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, dmean.data(:,3*p1(k)-3+p2(m)),'k','LineWidth',2);
axis([min(t) tmax -Inf Inf])
else
pl=plot(t, dmean.data(:,3*p1(k)-3+p2(m)),'k','LineWidth',2);
set(pl,'color',colors2{mod(al-1,length(colors))+1}) %al has 7 colors, should start over with blue after 7 lines
if names==0
st{al} = ['M. ' num2str(p1(k)) ', dim. ' num2str(p2(m))];
elseif names==1
st{al} = ['M. ' char(d(di).markerName{p1(k)}) ', dim. ' num2str(p2(m))];
end
axis([min(t) tmax -Inf Inf])
al=al+1;
hold on
end
end
end
elseif strcmp(d(1).type, 'norm data')
al=1;%amount of lines - for 'comb' plotting
%plot(t, dmean.data(:,p1),'k','LineWidth',2);
for k=1:length(p1)
for m=1%:length(p2)
if strcmp(plotopt, 'sep')
subplot(length(p1), 1, k)
plot(t, dmean.data(:,p1(k)),'k','LineWidth',2);
else
pl=plot(t, dmean.data(:,p1(k)),'k','LineWidth',2); %FIXBB110102: 'comb' also for norm data
set(pl,'color',colors2{mod(al-1,length(colors))+1}) %al has 7 colors, should start over with blue after 7 lines
if names==0
st{al} = ['M. ' num2str(p1(k))];
elseif names==1
st{al} = ['M. ' char(d(di).markerName{p1(k)})];
end
al=al+1;
hold on
end
end
end
elseif strcmp(d(1).type, 'segm data')
disp('plotting of array mean not implemented for segment data')
end
if strcmp(plotopt, 'comb') %plot legend
leg=legend(st, 'Location', 'EastOutside');
end
end %of if plotmean
else % direct reference to data
if ~exist('p1')
p1=1;
end
d=d(:);
plot(d(:,p1));
end
hold off
end
function m=name2number(d, marker)
m=[];
for i=1:length(marker)
if isfield(d,'markerName') %mocap or norm structure
for j=1:length(d.markerName)
if strcmp(char(marker{i}),char(d.markerName{j}))
m=[m,j];
end
end
elseif isfield(d,'segmentName') %segment structure
for j=1:length(d.segmentName)
if strcmp(char(marker{i}),char(d.segmentName{j}))
m=[m,j];
end
end
end
end
if length(m)<length(marker)
x=length(marker)-length(m);
str=sprintf([10 '%d marker(s) not matching with marker names in the given MoCap Structure.', x, 10]);
disp([10, str, 10])
end
end