Rev | Line | |
---|
[37] | 1 | function [r, c] = size(q, dim) |
---|
| 2 | % SIZE Size of matrix. |
---|
| 3 | % (Quaternion overloading of standard Matlab function.) |
---|
| 4 | |
---|
| 5 | % Copyright © 2005 Stephen J. Sangwine and Nicolas Le Bihan. |
---|
| 6 | % See the file : Copyright.m for further details. |
---|
| 7 | |
---|
| 8 | error(nargchk(1, 2, nargin)), error(nargoutchk(0, 2, nargout)) |
---|
| 9 | |
---|
| 10 | xq = x(q); [xr, xc] = size(xq); |
---|
| 11 | if ispure(q) |
---|
| 12 | if [xr, xc] ~= size(y(q)) | [xr, xc] ~= size(z(q)) |
---|
| 13 | error('Sizes within object differ.') |
---|
| 14 | end |
---|
| 15 | else |
---|
| 16 | if size(s(q)) ~= [xr, xc] | [xr, xc] ~= size(y(q)) | [xr, xc] ~= size(z(q)) |
---|
| 17 | error('Sizes within object differ.') |
---|
| 18 | end |
---|
| 19 | end |
---|
| 20 | |
---|
| 21 | % In what follows, we use the size of the x component of the quaternion, not the size |
---|
| 22 | % of the scalar part, since this could be empty. Otherwise the choice is arbitrary, |
---|
| 23 | % since the code above checks that all components of q have the same size. |
---|
| 24 | |
---|
| 25 | switch nargout |
---|
| 26 | case 0 |
---|
| 27 | switch nargin |
---|
| 28 | case 1 |
---|
| 29 | size(xq) |
---|
| 30 | case 2 |
---|
| 31 | size(xq, dim) |
---|
| 32 | end |
---|
| 33 | case 1 |
---|
| 34 | switch nargin |
---|
| 35 | case 1 |
---|
| 36 | r = [xr, xc]; |
---|
| 37 | case 2 |
---|
| 38 | r = size(xq, dim); |
---|
| 39 | end |
---|
| 40 | case 2 |
---|
| 41 | switch nargin |
---|
| 42 | case 1 |
---|
| 43 | [r, c] = size(xq); |
---|
| 44 | case 2 |
---|
| 45 | [r, c] = size(xq, dim); |
---|
| 46 | end |
---|
| 47 | otherwise |
---|
| 48 | error('Unhandled case.') |
---|
| 49 | end |
---|
| 50 | |
---|
| 51 | |
---|
| 52 | |
---|
Note: See
TracBrowser
for help on using the repository browser.