Skip to content

Commit e15180f

Browse files
committed
fix casts in RangeDimension and allow for Matlab style indexing ...
(start with index 1) and add test cases
1 parent 5ed37ef commit e15180f

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

+nix/RangeDimension.m

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@
1919
end
2020

2121
function tickAt = tick_at(obj, index)
22+
if index > 0
23+
index = index - 1;
24+
end
2225
func_name = strcat(obj.alias, '::tick_at');
23-
tickAt = nix_mx(func_name, obj.nix_handle, unit64(index));
26+
tickAt = nix_mx(func_name, obj.nix_handle, uint64(index));
2427
end
2528

2629
function indexOf = index_of(obj, position)
@@ -32,9 +35,12 @@
3235
if nargin < 3
3336
startIndex = 0;
3437
end
38+
if(startIndex > 0)
39+
startIndex = startIndex - 1;
40+
end
3541

3642
func_name = strcat(obj.alias, '::axis');
37-
axis = nix_mx(func_name, obj.nix_handle, unit64(count), uint64(startIndex));
43+
axis = nix_mx(func_name, obj.nix_handle, uint64(count), uint64(startIndex));
3844
end
3945

4046
end

tests/TestDimensions.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,15 @@
9595
assert(isempty(d1.label));
9696
assert(isempty(d1.unit));
9797
assert(isequal(d1.ticks, ticks));
98-
98+
99+
axis = d1.axis(3, 0);
100+
assert(axis(1) == ticks(1));
101+
assert(length(axis) == 3);
102+
assert(axis(end) == ticks(length(axis)));
103+
104+
assert(d1.tick_at(0) == ticks(1));
105+
assert(d1.tick_at(3) == ticks(3));
106+
99107
new_ticks = [5 6 7 8];
100108
d1.label = 'foo';
101109
d1.unit = 'mV';

0 commit comments

Comments
 (0)