How to Implement equationsToMatrix command

9 visualizaciones (últimos 30 días)
ercan duzgun
ercan duzgun el 26 de Feb. de 2021
Comentada: Walter Roberson el 26 de Feb. de 2021
From the paper of "Direct Displacement Analysis of a Stewart Platform Mechanism (Der-Ming Ku, 1997)", I am trying to check the equations in the paper symbolically.
The equations as follows:
My code in MATLAB is as follows:
clear all;close all;clc;
syms br pr bs ps bt pt
syms b1 b2 b3 mr ms mt real positive
syms POrx POry POrz real
syms POsx POsy POsz real
syms POtx POty POtz real
POr=[POrx POry POrz]';
POs=[POsx POsy POsz]';
POt=[POtx POty POtz]';
i=[1 0 0]';j=[0 1 0]';k=[0 0 1]';
wr=cos(br)*cos(pr)*i+sin(br)*cos(pr)*j+sin(pr)*k
ws=cos(bs)*cos(ps)*i+sin(bs)*cos(ps)*j+sin(ps)*k
wt=cos(bt)*cos(pt)*i+sin(bt)*cos(pt)*j+sin(pt)*k
Pr=POr+mr*wr
Ps=POs+ms*ws
Pt=POt+mt*wt
f=norm(Pr-Ps)^2-b1^2
g=norm(Ps-Pt)^2-b2^2
h=norm(Pt-Pr)^2-b1^2
[A,b] = equationsToMatrix([f;g;h],[pr,ps,pt])
I receive error if I run the code. The error I receive is this:
Error using symengine
Not a square matrix.
Error in sym/privBinaryOp (line 1032)
Csym = mupadmex(op,args{1}.s, args{2}.s, varargin{:});
Error in ^ (line 332)
B = privBinaryOp(A, p, 'symobj::mpower');
Error in Program1_sembolik (line 23)
f=(Pr-Ps)^2-b1^2
How can I find the expressions in equation in 7a, 7b,7c and A1 A2 A3 ?
Thanks in advance.

Respuestas (1)

Walter Roberson
Walter Roberson el 26 de Feb. de 2021
f=(Pr-Ps).^2-b1^2
  2 comentarios
ercan duzgun
ercan duzgun el 26 de Feb. de 2021
Dear @Walter Roberson , thank you very much for your answer. However, I am having this error:
>> [A,b] = equationsToMatrix([f],[pr,ps])
Error using mupadengine/feval_internal (line 172)
Unable to convert to matrix form because the system does not seem to be linear.
Error in sym/equationsToMatrix (line 61)
T = eng.feval_internal('symobj::equationsToMatrix',eqns,vars);
.
If I execute have this error , if I run this command:
>> f=(Pr-Ps).^2-b1^2
g=(Ps-Pt).^2-b2^2
h=(Pt-Pr).^2-b1^2
[A,b] = equationsToMatrix([f;g;h],[pr,ps,pt])
f =
(POrx - POsx + mr*cos(br)*cos(pr) - ms*cos(bs)*cos(ps))^2 - b1^2
(POry - POsy + mr*cos(pr)*sin(br) - ms*cos(ps)*sin(bs))^2 - b1^2
(POrz - POsz + mr*sin(pr) - ms*sin(ps))^2 - b1^2
g =
(POsx - POtx + ms*cos(bs)*cos(ps) - mt*cos(bt)*cos(pt))^2 - b2^2
(POsy - POty + ms*cos(ps)*sin(bs) - mt*cos(pt)*sin(bt))^2 - b2^2
(POsz - POtz + ms*sin(ps) - mt*sin(pt))^2 - b2^2
h =
(POrx - POtx + mr*cos(br)*cos(pr) - mt*cos(bt)*cos(pt))^2 - b1^2
(POry - POty + mr*cos(pr)*sin(br) - mt*cos(pt)*sin(bt))^2 - b1^2
(POrz - POtz + mr*sin(pr) - mt*sin(pt))^2 - b1^2
Error using mupadengine/feval_internal (line 172)
Unable to convert to matrix form because the system does not seem to be linear.
Error in sym/equationsToMatrix (line 61)
T = eng.feval_internal('symobj::equationsToMatrix',eqns,vars);
How can I solve this error?
Walter Roberson
Walter Roberson el 26 de Feb. de 2021
You cannot solve that. EquationsToMatrix is trying to separate out the set of expressions into the form Matrix*(vars.') + Residue, which can only be done for linear equations, but your system is not linear.
What you can do is create new variables like COSpr SINpr and subs() those in for cos(pr) and sin(pr), getting [f;g;h] that is linear in those variables. You could also subs(EXPRESSION, sin(pr), sqrt(1-COSpr)^2) to reduce the variables, but if you do that then you risk losing the proper sign unless you take extra care to introduce an extra variable to hold the sign.

Iniciar sesión para comentar.

Categorías

Más información sobre Formula Manipulation and Simplification en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by