how can i rewrite an equation base on variables
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Birdman
2017-12-9
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 个评论
Walter Roberson
2017-12-22
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!