Discussion:
How do I store Symbolic matrix?
r1f1
2018-11-22 21:48:47 UTC
Permalink
In the code below I try to store the 8 symbolic matrix in MatRot:

/ MatRot = zeros(4,4,8);

pkg load symbolic

theta = sym('theta',[1 8]);
d = sym('d',[1 8]);
alpha = sym('alpha',[1 8]);
a = sym ('a',[1 8]);

for i=1:8
MatRot(:,:,i) = [[cos(theta(1,i)), -cos(alpha(1,i))*sin(theta(1,i)),
sin(alpha(1,i))*sin(theta(1,i)), a(1,i)*cos(theta(1,i))];
[sin(theta(1,i)), cos(alpha(1,i))*cos(theta(1,i)),
-sin(alpha(1,i))*cos(theta(1,i)), a(1,i)*sin(theta(1,i))];
[0, sin(alpha(1,i)), cos(alpha(1,i)), d(1,i)];
[0, 0, 0, 1]];
end/

But octave give me the next error:

/error: operator =: no conversion for assignment of 'class' to indexed
'matrix'
error: called from
SymbolicMatRot at line 14 column 17/

I found that in matlab I can create a Symbolic Multidimensional Arrays like
this:

/A = sym('a',[2 2 2])
A(:,:,1) =
[ a1_1_1, a1_2_1]
[ a2_1_1, a2_2_1]
A(:,:,2) =
[ a1_1_2, a1_2_2]
[ a2_1_2, a2_2_2]/

But octave give this error:

/error: Cannot create symbolic matrix with that size
error: called from
assert at line 94 column 11
make_sym_matrix at line 23 column 3
sym at line 328 column 9/

I don't know another form to store this. I'm using win7 with GNU Octave
Version: 4.4.1 and symbolic version 2.7.1





--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Colin Macdonald
2018-11-22 22:44:19 UTC
Permalink
Post by r1f1
MatRot(:,:,i) = [[cos(theta(1,i)), -cos(alpha(1,i))*sin(theta(1,i)),
sin(alpha(1,i))*sin(theta(1,i)), a(1,i)*cos(theta(1,i))];
[sin(theta(1,i)), cos(alpha(1,i))*cos(theta(1,i)),
-sin(alpha(1,i))*cos(theta(1,i)), a(1,i)*sin(theta(1,i))];
[0, sin(alpha(1,i)), cos(alpha(1,i)), d(1,i)];
[0, 0, 0, 1]];
This is unfortunately a well-known bug. Replace that last row with

[sym(0), 0, 0, 1]];

and it will work. This is a bug in the Octave interpreter:

https://savannah.gnu.org/bugs/?42152

Colin
r1f1
2018-11-22 22:53:04 UTC
Permalink
Even changing that keeps giving me the same error



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Colin Macdonald
2018-11-23 06:06:40 UTC
Permalink
Post by r1f1
Even changing that keeps giving me the same error
I'm sorry I didn't read carefully enough.

1. We do not (yet) support multidim symbolic arrays.

2. We don't support assignment of symbolic things into double matrices.
I.e., this will fail:

A = zeros(2,2)
A(1,2) = sym('x')

That's probably true with the Matlab toolbox as well.

Colin
r1f1
2018-11-24 11:39:06 UTC
Permalink
thanks for the answer. At the end I rewrite the code to passing the variable
i like an argument and in the command windows I store the matrix, it's quite
inefficient but for me it's ok.



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Loading...