Line | |
---|
1 | function p = convert(q, t) |
---|
2 | % CONVERT Convert elements of a quaternion to another type. |
---|
3 | % |
---|
4 | % This function converts a quaternion array into a quaternion array with |
---|
5 | % components of a different data type (e.g. int8, double, single). |
---|
6 | |
---|
7 | % Copyright © 2006 Stephen J. Sangwine and Nicolas Le Bihan. |
---|
8 | % See the file : Copyright.m for further details. |
---|
9 | |
---|
10 | error(nargchk(2, 2, nargin)), error(nargoutchk(0, 1, nargout)) |
---|
11 | |
---|
12 | if ~ischar(t) |
---|
13 | error('Second parameter must be a string.') |
---|
14 | end |
---|
15 | |
---|
16 | f = str2func(t); % Construct a function handle from t, which must denote |
---|
17 | % a function on the current Matlab path, so if it does |
---|
18 | % not, an error will occur here. |
---|
19 | if ispure(q) |
---|
20 | p = quaternion( f(x(q)), f(y(q)), f(z(q))); |
---|
21 | else |
---|
22 | p = quaternion(f(s(q)), f(x(q)), f(y(q)), f(z(q))); |
---|
23 | end |
---|
Note: See
TracBrowser
for help on using the repository browser.