-
Notifications
You must be signed in to change notification settings - Fork 15
/
Gvel.m
774 lines (773 loc) · 30.5 KB
/
Gvel.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
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
classdef Gvel < handle
% Gvel: GNSS velocity class
% ---------------------------------------------------------------------
% Gvel Declaration:
% gvel = Gvel(); Create empty gt.Gvel object
%
% gvel = Gvel(vel, 'type', [orgpos], ['orgtype']);
% Create gt.Gerr object from velocity vector
% vel : Mx3, Velocity vector
% [ECEF x(m/s), ECEF y(m/s), ECEF z(m/s)] or
% [east(m/s), north(m/s), up(m/s)]
% veltype : Coordinate type: 'xyz' or 'enu'
% [orgpos] : 1x3, Coordinate origin position vector
% [latitude(deg), longitude(deg), ellipsoidal height(m)] or
% [ECEF x(m), ECEF y(m), ECEF z(m)]
% [orgtype]: 1x1, Coordinate type: 'llh' or 'xyz'
% ---------------------------------------------------------------------
% Gvel Properties:
% n : 1x1, Number of epochs
% xyz :(obj.n)x3, ECEF velocity (m/s, m/s, m/s)
% enu :(obj.n)x3, Local ENU velocity (m/s, m/s, m/s)
% orgllh : 1x3, Coordinate origin (deg, deg, m)
% orgxyz : 1x3, Coordinate origin in ECEF (m, m, m)
% v2 :(obj.n)x1, 2D (horizontal) velocity (m/s)
% v3 :(obj.n)x1, 3D velocity (m/s)
% ---------------------------------------------------------------------
% Gvel Methods:
% setVel(vel, veltype); Set velocity
% setOrg(pos, postype); Set coordinate origin
% setOrgGpos(gpos); Set coordinate origin by gt.Gpos
% insert(idx, gvel); Insert gt.Gvel object
% append(gvel); Append gt.Gvel object
% addOffset(offset, [coordtype]); Add offset to velocity data
% gerr = difference(gvel); Compute difference between two gt.Gvel objects
% gpos = integral(dt, [idx]); Cumulative integral
% gvel = copy(); Copy object
% gvel = select([idx]); Select velocity from index
% [gvel, gcov] = mean([idx]): Compute mean and variance of velocity
% [mxyz, sdxyz] = meanXYZ([idx]); Compute mean and standard deviation of ECEF velocity
% [menu, sdenu] = meanENU([idx]); Compute mean and standard deviation of ENU velocity
% [m2d, sd2d] = mean2D([idx]); Compute mean and standard deviation of 2D velocity
% [m3d, sd3d] = mean3D([idx]); Compute mean and standard deviation of 3D velocity
% x = x([idx]); Get X-component of ECEF velocity
% y = y([idx]); Get Y-component of ECEF velocity
% z = z([idx]); Get Z-component of ECEF velocity
% east = east([idx]); Get East-component of ENU velocity
% north = north([idx]); Get North-component of ENU velocity
% up = up([idx]); Get Up-component of ENU velocity
% plot([idx]); Plot ENU velocity
% plotXYZ([idx]); Plot ECEF velocity
% plot2D([idx]); Plot 2D velocity
% plot3D([idx]); Plot 3D velocity
% help(); Show help
% ---------------------------------------------------------------------
% Gvel Overloads:
% gerr = obj - gvel; Compute difference between two gt.Gvel objects
% ---------------------------------------------------------------------
% Author: Taro Suzuki
%
properties
n % Number of epochs
xyz % ECEF velocity (m/s, m/s, m/s)
enu % Local ENU velocity (m/s, m/s, m/s)
orgllh % Coordinate origin (deg, deg, m)
orgxyz % Coordinate origin in ECEF (m, m, m)
v2 % 2D (horizontal) velocity (m/s)
v3 % 3D velocity (m/s)
end
methods
%% constructor
function obj = Gvel(varargin)
if nargin==0; obj.n = 0; end % generate empty object
if nargin>=2; obj.setVel(varargin{1}, varargin{2}); end
if nargin==4; obj.setOrg(varargin{3}, varargin{4}); end
end
%% setVel
function setVel(obj, vel, veltype)
% setVel: Set velocity
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% obj.setVel(vel, veltype)
%
% Input: ------------------------------------------------------
% vel : Mx3, Velocity vector
% veltype: 1x1, Coordinate type: 'xyz' or 'enu'
%
arguments
obj gt.Gvel
vel (:,3) double
veltype (1,:) char {mustBeMember(veltype,{'xyz','enu'})}
end
obj.n = size(vel,1);
switch veltype
case 'xyz'
obj.xyz = vel;
if ~isempty(obj.orgllh); obj.enu = rtklib.ecef2enu(obj.xyz, obj.orgllh); end
case 'enu'
obj.enu = vel;
if ~isempty(obj.orgllh); obj.xyz = rtklib.enu2ecef(obj.enu, obj.orgllh); end
end
if ~isempty(obj.enu)
obj.v2 = vecnorm(obj.enu(:,1:2), 2, 2);
obj.v3 = vecnorm(obj.enu, 2, 2);
else
obj.v3 = vecnorm(obj.xyz, 2, 2);
end
end
%% setOrg
function setOrg(obj, org, orgtype)
% setOrg: Set coordinate origin
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% obj.setOrg(org, orgtype)
%
% Input: ------------------------------------------------------
% org : 1x3, Coordinate origin
% orgtype: 1x1, Coordinate type: 'llh' or 'xyz'
%
arguments
obj gt.Gvel
org (1,3) double
orgtype (1,:) char {mustBeMember(orgtype,{'llh','xyz'})}
end
switch orgtype
case 'llh'
obj.orgllh = org;
obj.orgxyz = rtklib.llh2xyz(org);
case 'xyz'
obj.orgxyz = org;
obj.orgllh = rtklib.xyz2llh(org);
end
if ~isempty(obj.xyz)
obj.enu = rtklib.ecef2enu(obj.xyz, obj.orgllh);
elseif ~isempty(obj.enu)
obj.xyz = rtklib.enu2ecef(obj.enu, obj.orgllh);
end
obj.v2 = vecnorm(obj.enu(:,1:2), 2, 2);
obj.v3 = vecnorm(obj.enu, 2, 2);
end
%% setOrgGpos
function setOrgGpos(obj, gpos)
% setOrgGpos: Set coordinate origin by gt.Gpos
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% obj.setOrgGpos(gpos)
%
% Input: ------------------------------------------------------
% gpos : 1x1, gt.Gpos, Coordinate origin position
%
arguments
obj gt.Gvel
gpos gt.Gpos
end
if isempty(gpos.llh)
error("gpos.llh is empty");
end
obj.setOrg(gpos.llh(1,:),"llh");
end
%% insert
function insert(obj, idx, gvel)
% insert: Insert gt.Gvel object
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% obj.insert(idx, gvel)
%
% Input: ------------------------------------------------------
% idx : 1x1, Integer index to insert
% gvel: 1x1, gt.Gvel object
%
arguments
obj gt.Gvel
idx (1,1) {mustBeInteger}
gvel gt.Gvel
end
if idx<=0 || idx>obj.n
error('Index is out of range');
end
if ~isempty(obj.xyz) && ~isempty(gvel.xyz)
obj.setVel(obj.insertdata(obj.xyz, idx, gvel.xyz), 'xyz');
else
obj.setVel(obj.insertdata(obj.enu, idx, gvel.enu), 'enu');
end
end
%% append
function append(obj, gvel)
% append: Append gt.Gvel object
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% obj.append(gvel)
%
% Input: ------------------------------------------------------
% gvel: 1x1, gt.Gvel object
%
arguments
obj gt.Gvel
gvel gt.Gvel
end
if ~isempty(obj.xyz)
obj.setVel([obj.xyz; gvel.xyz], 'xyz');
else
obj.setVel([obj.enu; gvel.enu], 'enu');
end
end
%% addOffset
function addOffset(obj, offset, coordtype)
% addOffset: Add offset to velocity data
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% obj.addOffset(offset, [coordtype[)
%
% Input: ------------------------------------------------------
% offset : Mx3 or 1x3, Velocity offset
% [coordtype]: 1x1, Coordinate type: 'xyz' or 'enu' (optional)
% Default: coordtype = 'enu'
%
arguments
obj gt.Gvel
offset (:,3) double
coordtype (1,:) char {mustBeMember(coordtype,{'enu','xyz'})} = 'enu'
end
if size(offset,1)~=obj.n && size(offset,1)~=1
error("Size of offset must be obj.n or 1");
end
switch coordtype
case 'enu'
if isempty(obj.enu)
error('enu must be set to a value');
end
obj.setVel(obj.enu + offset, 'enu');
case 'xyz'
if isempty(obj.xyz)
error('xyz must be set to a value');
end
obj.setVel(obj.xyz + offset, 'xyz');
end
end
%% difference
function gerr = difference(obj, gvel)
% difference : Compute difference between two gt.Gvel objects
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% obj.difference(gvel)
%
% Input: ------------------------------------------------------
% gvel: 1x1, gt.Gvel object
%
% Output: -----------------------------------------------------
% gerr: 1x1, gt.Gerr object
%
arguments
obj gt.Gvel
gvel gt.Gvel
end
if obj.n ~= gvel.n && gvel.n ~= 1
error('Size of gvel must be obj.n or 1')
end
if ~isempty(obj.xyz) && ~isempty(gvel.xyz)
gerr = gt.Gerr('velocity', obj.xyz - gvel.xyz, 'xyz');
if ~isempty(obj.orgllh); gerr.setOrg(obj.orgllh, 'llh'); end
elseif ~isempty(obj.enu) && ~isempty(gvel.enu)
gerr = gt.Gerr('velocity', obj.enu - gvel.enu, 'enu');
if ~isempty(obj.orgllh); gerr.setOrg(obj.orgllh, 'llh'); end
else
error('two gt.Gvel must have both xyz or enu')
end
end
%% integral
function gpos = integral(obj, dt, idx)
% integral: Cumulative integral
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% obj.integral(dt, [idx])
%
% Input: ------------------------------------------------------
% dt : 1x1, Time step (s)
% [idx]: Logical or numeric index to select (optional)
% Default: idx = 1:obj.n
%
% Output: -----------------------------------------------------
% gpos : 1x1, gt.Gpos object
%
arguments
obj gt.Gvel
dt (1,1) double
idx {mustBeInteger, mustBeVector} = 1:obj.n
end
if ~isempty(obj.xyz)
xyz_ = cumtrapz(dt*obj.xyz(idx,:));
gpos = gt.Gpos(xyz_, 'xyz');
else
enu_ = cumtrapz(dt*obj.enu(idx,:));
gpos = gt.Gpos(enu_, 'enu');
end
if ~isempty(obj.orgllh); gpos.setOrg(obj.orgllh, 'llh'); end
end
%% copy
function gvel = copy(obj)
% copy: Copy object
% -------------------------------------------------------------
% MATLAB handle class is used, so if you want to create a
% different object, you need to use the copy method.
%
% Usage: ------------------------------------------------------
% gvel = obj.copy()
%
% Output: -----------------------------------------------------
% gvel: 1x1, Copied gt.Gvel object
%
arguments
obj gt.Gvel
end
gvel = obj.select(1:obj.n);
end
%% select
function gvel = select(obj, idx)
% select : Select velocity from index
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% gvel = obj.select(idx)
%
% Input: ------------------------------------------------------
% idx : Logical or numeric index to select
%
% Output: -----------------------------------------------------
% gvel : 1x1, Selected gt.Gvel object
%
arguments
obj gt.Gvel
idx {mustBeInteger, mustBeVector}
end
if ~any(idx)
error('Selected index is empty');
end
if ~isempty(obj.xyz)
gvel = gt.Gvel(obj.xyz(idx,:), 'xyz');
else
gvel = gt.Gvel(obj.enu(idx,:), 'enu');
end
if ~isempty(obj.orgllh); gvel.setOrg(obj.orgllh, 'llh'); end
end
%% mean
function [gvel, gcov] = mean(obj, idx)
% mean: Compute mean and variance of velocity
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% [gvel, gcov] = obj.mean([idx])
%
% Input: ------------------------------------------------------
% [idx]: Logical or numeric index to select (optional)
% Default: idx = 1:obj.n
%
% Output: -----------------------------------------------------
% gvel : 1x1, gt.Gvel object with mean velocity
% gcov : 1x1, gt.Gcov object
%
arguments
obj gt.Gvel
idx {mustBeInteger, mustBeVector} = 1:obj.n
end
if ~isempty(obj.enu)
menu = obj.meanENU(idx);
gvel = gt.Gvel(menu, 'enu');
else
mxyz = obj.meanXYZ(idx);
gvel = gt.Gvel(mxyz, 'xyz');
end
if ~isempty(obj.orgllh)
gvel.setOrg(obj.orgllh,'llh');
end
gcov = gt.Gcov(obj);
end
%% meanXYZ
function [mxyz, sdxyz] = meanXYZ(obj, idx)
% meanXYZ: Compute mean and standard deviation of ECEF velocity
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% [mxyz, sdxyz] = obj.meanXYZ([idx])
%
% Input: ------------------------------------------------------
% [idx] : Logical or numeric index to select (optional)
% Default: idx = 1:obj.n
%
% Output: -----------------------------------------------------
% mxyz : Mx3, Mean of ECEF velocities (m/s)
% sdxyz: 1x3, Standard deviation of ECEF velocities (m/s)
%
arguments
obj gt.Gvel
idx {mustBeInteger, mustBeVector} = 1:obj.n
end
if isempty(obj.xyz)
error('xyz must be set to a value');
end
mxyz = mean(obj.xyz(idx,:), 1, 'omitnan');
sdxyz = std(obj.xyz(idx,:), 0, 1, 'omitnan');
end
%% meanENU
function [menu, sdenu] = meanENU(obj, idx)
% meanENU: Compute mean and standard deviation of ENU velocity
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% obj.meanENU([idx])
%
% Input: ------------------------------------------------------
% [idx] : Logical or numeric index to select (optional)
% Default: idx = 1:obj.n
%
% Output: -----------------------------------------------------
% menu : Mx3, Mean of ENU velocities
% sdenu: 1x3, Standard deviation of ENU velocity
%
arguments
obj gt.Gvel
idx {mustBeInteger, mustBeVector} = 1:obj.n
end
if isempty(obj.enu)
error('enu must be set to a value');
end
menu = mean(obj.enu(idx,:), 1, 'omitnan');
sdenu = std(obj.enu(idx,:), 0, 1, 'omitnan');
end
%% mean2D
function [m2d, sd2d] = mean2D(obj, idx)
% mean2D: Compute mean and standard deviation of 2D velocity
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% obj.mean2D([idx])
%
% Input: ------------------------------------------------------
% [idx] : Logical or numeric index to select (optional)
% Default: idx = 1:obj.n
%
% Output: -----------------------------------------------------
% m2d : Mx1, Mean of 2D (horizontal) velocities
% sd2d : 1x1, Standard deviation of 2D (horizontal) velocities
%
arguments
obj gt.Gvel
idx {mustBeInteger, mustBeVector} = 1:obj.n
end
if isempty(obj.v2)
error('enu must be set to a value');
end
m2d = mean(obj.v2(idx), 1, 'omitnan');
sd2d = std(obj.v2(idx), 0, 1, 'omitnan');
end
%% mean3D
function [m3d, sd3d] = mean3D(obj, idx)
% mean3D : Compute mean and standard deviation of 3D velocity
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% obj.mean3D([idx])
%
% Input: ------------------------------------------------------
% [idx] : Logical or numeric index to select (optional)
% Default: idx = 1:obj.n
%
% Output: -----------------------------------------------------
% m3d : Mx1, Mean of 3D velocities
% sd3d : 1x1, Standard deviation of 3D velocities
%
arguments
obj gt.Gvel
idx {mustBeInteger, mustBeVector} = 1:obj.n
end
m3d = mean(obj.v3(idx), 1, 'omitnan');
sd3d = std(obj.v3(idx), 0, 1, 'omitnan');
end
%% x
function x = x(obj, idx)
% x : Get X-component of ECEF velocity
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% obj.x([idx])
%
% Input: ------------------------------------------------------
% [idx] : Logical or numeric index to select (optional)
% Default: idx = 1:obj.n
%
% Output: -----------------------------------------------------
% x : Mx1, X-component of ECEF velocity
%
arguments
obj gt.Gvel
idx {mustBeInteger, mustBeVector} = 1:obj.n
end
if isempty(obj.xyz)
error('xyz must be set to a value');
end
x = obj.xyz(idx,1);
end
%% y
function y = y(obj, idx)
% y : Get Y-component of ECEF velocity
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% obj.y([idx])
%
% Input: ------------------------------------------------------
% [idx] : Logical or numeric index to select (optional)
% Default: idx = 1:obj.n
%
% Output: -----------------------------------------------------
% y : Mx1, Y-component of ECEF velocity
%
arguments
obj gt.Gvel
idx {mustBeInteger, mustBeVector} = 1:obj.n
end
if isempty(obj.xyz)
error('xyz must be set to a value');
end
y = obj.xyz(idx,2);
end
%% z
function z = z(obj, idx)
% z : Get Z-component of ECEF velocity
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% obj.z([idx])
%
% Input: ------------------------------------------------------
% [idx] : Logical or numeric index to select (optional)
% Default: idx = 1:obj.n
%
% Output: -----------------------------------------------------
% z : Mx1, Z-component of ECEF velocity
%
arguments
obj gt.Gvel
idx {mustBeInteger, mustBeVector} = 1:obj.n
end
if isempty(obj.xyz)
error('xyz must be set to a value');
end
z = obj.xyz(idx,3);
end
%% east
function east = east(obj, idx)
% east : Get East-component of ENU velocity
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% obj.east([idx])
%
% Input: ------------------------------------------------------
% [idx] : Logical or numeric index to select (optional)
% Default: idx = 1:obj.n
%
% Output: -----------------------------------------------------
% east : Mx1, East-component of ENU velocity
%
arguments
obj gt.Gvel
idx {mustBeInteger, mustBeVector} = 1:obj.n
end
if isempty(obj.enu)
error('enu must be set to a value');
end
east = obj.enu(idx,1);
end
%% north
function north = north(obj, idx)
% north : Get North-component of ENU velocity
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% obj.north([idx])
%
% Input: ------------------------------------------------------
% [idx] : Logical or numeric index to select (optional)
% Default: idx = 1:obj.n
%
% Output: -----------------------------------------------------
% north : Mx1, North-component of ENU velocity
%
arguments
obj gt.Gvel
idx {mustBeInteger, mustBeVector} = 1:obj.n
end
if isempty(obj.enu)
error('enu must be set to a value');
end
north = obj.enu(idx,2);
end
%% up
function up = up(obj, idx)
% up : Get Up-component of ENU velocity
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% obj.up([idx])
%
% Input: ------------------------------------------------------
% [idx] : Logical or numeric index to select (optional)
% Default: idx = 1:obj.n
%
% Output: -----------------------------------------------------
% up : Mx1, Up-component of ENU velocity
%
arguments
obj gt.Gvel
idx {mustBeInteger, mustBeVector} = 1:obj.n
end
if isempty(obj.enu)
error('enu must be set to a value');
end
up = obj.enu(idx,3);
end
%% plot
function plot(obj, idx)
% plot : Plot ENU velocity
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% obj.plot([idx])
%
% Input: ------------------------------------------------------
% [idx] : Logical or numeric index to select (optional)
% Default: idx = 1:obj.n
%
arguments
obj gt.Gvel
idx {mustBeInteger, mustBeVector} = 1:obj.n
end
if isempty(obj.enu)
error('enu must be set to a value');
end
figure;
tiledlayout(3,1,'TileSpacing','Compact');
nexttile;
plot(obj.enu(idx, 1), '.-');
ylabel('East (m/s)');
grid on;
nexttile;
plot(obj.enu(idx, 2), '.-');
ylabel('North (m/s)');
grid on;
nexttile;
plot(obj.enu(idx, 3), '.-');
ylabel('Up (m/s)');
grid on;
end
%% plotXYZ
function plotXYZ(obj, idx)
% plotXYZ : Plot ECEF velocity
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% obj.plotXYZ([idx])
%
% Input: ------------------------------------------------------
% [idx] : Logical or numeric index to select (optional)
% Default: idx = 1:obj.n
%
arguments
obj gt.Gvel
idx {mustBeInteger, mustBeVector} = 1:obj.n
end
if isempty(obj.xyz)
error('enu must be set to a value');
end
figure;
tiledlayout(3,1,'TileSpacing','Compact');
a1 = nexttile;
plot(obj.xyz(idx, 1), '.-');
ylabel('X (m/s)');
grid on;
a2 = nexttile;
plot(obj.xyz(idx, 2), '.-');
ylabel('Y (m/s)');
grid on;
a3 = nexttile;
plot(obj.xyz(idx, 3), '.-');
ylabel('Z (m/s)');
grid on;
linkaxes([a1 a2 a3],'x');
drawnow
end
%% plot2D
function plot2D(obj, idx)
% plot2D : Plot 2D velocity
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% obj.plot2D([idx])
%
% Input: ------------------------------------------------------
% [idx] : Logical or numeric index to select (optional)
% Default: idx = 1:obj.n
%
arguments
obj gt.Gvel
idx {mustBeInteger, mustBeVector} = 1:obj.n
end
if isempty(obj.v2)
error('enu must be set to a value');
end
figure;
plot(obj.v2(idx), '.-');
ylabel('Horizontal velocity (m/s)');
grid on;
drawnow
end
%% plot3D
function plot3D(obj, idx)
% plot3D : Plot 3D velocity
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% obj.plot3D([idx])
%
% Input: ------------------------------------------------------
% [idx] : Logical or numeric index to select (optional)
% Default: idx = 1:obj.n
%
arguments
obj gt.Gvel
idx {mustBeInteger, mustBeVector} = 1:obj.n
end
figure;
plot(obj.v3(idx), '.-');
ylabel('3D velocity (m/s)');
grid on;
drawnow
end
%% help
function help(~)
% help: Show help
doc gt.Gvel
end
%% overload
function gerr = minus(obj, gvel)
% minus: Subtract two Gvel objects
% -------------------------------------------------------------
%
% Usage: ------------------------------------------------------
% obj-gvel
%
% Input: ------------------------------------------------------
% gvel : gt.Gvel object
%
% Output: -----------------------------------------------------
% gerr : gt.Gerr object
%
gerr = obj.difference(gvel);
end
end
%% Private functions
methods(Access=private)
%% Insert data
function c = insertdata(~,a,idx,b)
c = [a(1:size(a,1)<idx,:); b; a(1:size(a,1)>=idx,:)];
end
end
end