# How to Implement equationsToMatrix command

34 views (last 30 days)
ercan duzgun on 26 Feb 2021
Commented: Walter Roberson on 26 Feb 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)
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 ?

Walter Roberson on 26 Feb 2021
f=(Pr-Ps).^2-b1^2
##### 2 CommentsShowHide 1 older comment
Walter Roberson on 26 Feb 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.

### Community Treasure Hunt

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

Start Hunting!

Translated by