how can i rewrite an equation base on variables
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
shahin hashemi
am 9 Dez. 2017
Kommentiert: Walter Roberson
am 22 Dez. 2017
dear all
i have 3*1 matrix like matrix E below
syms qd td ed q teta
E =[ ed*cos(q)*sin(teta) - cos(teta)*(qd*cos(q)*sin(teta) + td*cos(teta)*sin(q)) - td*sin(q)*sin(teta)^2 ; cos(teta)*(td*cos(teta)*sin(q) - qd*sin(q)*sin(teta)) + ed*sin(q)*sin(teta) + td*cos(q)*sin(teta)^2 ; ed*cos(teta) + cos(q)*sin(teta)*(qd*cos(q)*sin(teta) + td*cos(teta)*sin(q)) - sin(q)*sin(teta)*(td*cos(teta)*sin(q) - qd*sin(q)*sin(teta))]
that i want to rewrite it in [3*3]*[qd;td;ed]=[E] this form
is there any Command that can help me to calculate this [3*3] matrix by matlab
answer should be like this:
[ -cos(q)*cos(teta)*sin(teta), - cos(teta)^2*sin(q) - sin(q)*sin(teta)^2, cos(q)*sin(teta)]
[ -cos(teta)*sin(q)*sin(teta), sin(q)*cos(teta)^2 + cos(q)*sin(teta)^2, sin(q)*sin(teta)]
[ cos(q)^2*sin(teta)^2 + sin(q)^2*sin(teta)^2, cos(q)*cos(teta)*sin(q)*sin(teta) - cos(teta)*sin(q)^2*sin(teta), cos(teta)]
i really apreciated if you could help me
0 Kommentare
Akzeptierte Antwort
Birdman
am 9 Dez. 2017
Try the following code:
syms qd td ed q teta
E =[ ed*cos(q)*sin(teta) - cos(teta)*(qd*cos(q)*sin(teta) + td*cos(teta)*sin(q)) - td*sin(q)*sin(teta)^2 ; cos(teta)*(td*cos(teta)*sin(q) - qd*sin(q)*sin(teta)) + ed*sin(q)*sin(teta) + td*cos(q)*sin(teta)^2 ; ed*cos(teta) + cos(q)*sin(teta)*(qd*cos(q)*sin(teta) + td*cos(teta)*sin(q)) - sin(q)*sin(teta)*(td*cos(teta)*sin(q) - qd*sin(q)*sin(teta))]
Ecollected=collect(E,[qd,td,ed])
for i=1:size(E,1)
E3by3form(i,:)=coeffs(Ecollected(i),[qd,td,ed])
end
Let me know the results. The answer you want is stored in E3by3form.
5 Kommentare
Walter Roberson
am 22 Dez. 2017
That cannot be solved.
x = sym('x',[1 6]);
consnt7(x)
ans(:,:,1) =
[ 0, 0, 0]
[ 0, 0, 0]
[ 0, 0, 0]
ans(:,:,2) =
[ 0, -sin(x1), cos(x1)*sin(x2)]
[ 0, cos(x1), sin(x1)*sin(x2)]
[ 1, 0, cos(x2)]
The first pane of the 3D answers can be solved, as it is already all 0. However, in the second pane, ans(:,:,2), there is no x1 such that -sin(x1) == 0 at the same time that cos(x1) == 0 -- and even if there were, the 1 in the bottom left corner, position ans(3,1,2), can never be equal to 0, so there is no possible input vector such that the result of the function is all zeros.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!