help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: re: arrayfun on quaternion arrays


From: octavecontrib
Subject: re: re: arrayfun on quaternion arrays
Date: Sun, 7 Jun 2020 15:22:19 +0530

arrayfun (@(x) abs(x), qqq, "uni", 0) ans = { [1,1] = 1 1 } ## (some people prefer '"UniformOutput", false') Is this the result you want?

  1. Is there a way to directly get a matrix as output rather than as a cell array?
  2. Since each application of the anonymous function returned the same datatype (double) with the same size (1x1), I expected UniformOutput=true would have worked. I would like to know why it didn't.
  3. Also it looks like the array function executes the anonymous function only ONE time instead of length(qqq) times as shown by the code below. In my actual code I want the anonymous function to be called length(qqq) times as the actual function is more complicated than the example.

qqq = [quaternion(1,0,0,0);
       quaternion(1,0,0,0);
       quaternion(2,0,0,0);];
%
qqq(1) * [1;2]  % this line works when ONE quaternion is passed to mtimes

arrayfun(@(x)[1; 2], qqq, 'UniformOutput', false) % this line indicates that the anonymous function is called only once.
arrayfun(@(x)x*[1; 2], qqq, 'UniformOutput', false) % this line throws an error as the total quaternion array is passed as such to the anonymous function.

Output
=====
ans.w =
   1
   2
ans.x =
   0
   0
ans.y =
   0
   0
ans.z =
   0
   0
ans =
{
  [1,1] =
     1
     2
}
error: mtimes: operator *: nonconformant arguments (op1 is 3x1, op2 is 2x1)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]