File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 158
158
end
159
159
160
160
% -----------------------------------------------------------
161
- % c++ to matlab array functions
161
+ % c++ vs matlab helper functions
162
162
% -----------------------------------------------------------
163
163
164
164
function r = transpose_array(data )
165
165
% Data must agree with file & dimensions; see mkarray.cc(42)
166
166
r = permute(data , length(size(data )): -1 : 1 );
167
167
end
168
+
169
+ function r = handle_index(idx )
170
+ % Matlab uses 1-based indexing opposed to 0 based indexing in C++.
171
+ % handle_index transforms a Matlab style index to a C++ style
172
+ % index and raises the appropriate Matlab error in case of an
173
+ % invalid subscript.
174
+ if (idx < 1 )
175
+ err.identifier = ' MATLAB:badsubscript' ;
176
+ err.message = ' Subscript indices must either be real positive integers or logicals.' ;
177
+ error(err );
178
+ end
179
+ r = idx - 1 ;
180
+ end
168
181
end
169
182
170
183
end
You can’t perform that action at this time.
0 commit comments