Solve 4 equations, 4 unknowns

26 visualizzazioni (ultimi 30 giorni)
Gregzy
Gregzy il 10 Apr 2018

Please forgive me if I have made a simple mistake somewhere, i am new to matlab. I am trying to solve 4 equations with 4 unknowns using the following code (the equations can be seen in the code):

clear all
clc
format shortEng
format compact
%Variables
mr1 = 0.00367;
mr2 = 0.00347;
mr3 = 0.00326;
mr4 = 0.00285;
t1 = (0.*pi./180); %Theta 1
t2 = (150.*pi./180); %Theta 2
L2 = 0.1; %Length 1 m
%Equations
syms t3 t4 L3 L4
eqn1 = (mr1.*cos(t1))+(mr2.*cos(t2))+(mr3.*cos(t3))+(mr4.*cos(t4));
eqn2 = (mr1.*sin(t1))+(mr2.*sin(t2))+(mr3.*sin(t3))+(mr4.*sin(t4));
eqn3 = (mr2.*cos(t2).*L2)+(mr3.*cos(t3).*L3)+(mr4.*cos(t4).*L4);
eqn4 = (mr2.*sin(t2).*L2)+(mr3.*sin(t3).*L3)+(mr4.*sin(t4).*L4);
sol = solve([eqn1, eqn2, eqn3, eqn4], [t3, t4, L3, L4]);
t3sol = sol.t3
t4sol = sol.t3
L3sol = sol.L3
L4sol = sol.L4

I get an outout with numbers like this:

t3sol =
  2*atan(455270576103713634351936474148609294958907416025443346905400201076875310485383426659707577536627793063540918127069111936252447223082571464794555202805902101116592729065123651354430891395310711^(1/2)/103772768504232210111428514992779755903579894629076944466599707421011792972435705624089995372733 - 783150673641568928799120402730188800000/112313626000065159014893967186374350903)
 -2*atan(455270576103713634351936474148609294958907416025443346905400201076875310485383426659707577536627793063540918127069111936252447223082571464794555202805902101116592729065123651354430891395310711^(1/2)/103772768504232210111428514992779755903579894629076944466599707421011792972435705624089995372733 + 783150673641568928799120402730188800000/112313626000065159014893967186374350903)
t4sol =
  2*atan(455270576103713634351936474148609294958907416025443346905400201076875310485383426659707577536627793063540918127069111936252447223082571464794555202805902101116592729065123651354430891395310711^(1/2)/103772768504232210111428514992779755903579894629076944466599707421011792972435705624089995372733 - 783150673641568928799120402730188800000/112313626000065159014893967186374350903)
 -2*atan(455270576103713634351936474148609294958907416025443346905400201076875310485383426659707577536627793063540918127069111936252447223082571464794555202805902101116592729065123651354430891395310711^(1/2)/103772768504232210111428514992779755903579894629076944466599707421011792972435705624089995372733 + 783150673641568928799120402730188800000/112313626000065159014893967186374350903)
L3sol =
 (639266908722361223894633416461491882974473854575*455270576103713634351936474148609294958907416025443346905400201076875310485383426659707577536627793063540918127069111936252447223082571464794555202805902101116592729065123651354430891395310711^(1/2))/26043649613544488547956741207035051924878829702661402288686733830167187403462770754918120682429582322225957569297285042848923291397477562528230268 + 8610446189192872062881087440073/293689728774632554402123708876852
 8610446189192872062881087440073/293689728774632554402123708876852 - (639266908722361223894633416461491882974473854575*455270576103713634351936474148609294958907416025443346905400201076875310485383426659707577536627793063540918127069111936252447223082571464794555202805902101116592729065123651354430891395310711^(1/2))/26043649613544488547956741207035051924878829702661402288686733830167187403462770754918120682429582322225957569297285042848923291397477562528230268
L4sol =
 8610446189192872062881087440073/293689728774632554402123708876852 - (72538865491225*455270576103713634351936474148609294958907416025443346905400201076875310485383426659707577536627793063540918127069111936252447223082571464794555202805902101116592729065123651354430891395310711^(1/2))/469869966593806228256848762044483359839753522072725494401599978519001765592358104563673245479461724152220562596
 (72538865491225*455270576103713634351936474148609294958907416025443346905400201076875310485383426659707577536627793063540918127069111936252447223082571464794555202805902101116592729065123651354430891395310711^(1/2))/469869966593806228256848762044483359839753522072725494401599978519001765592358104563673245479461724152220562596 + 8610446189192872062881087440073/293689728774632554402123708876852

How can I simplify my output numbers so i get the format of the theta values to be xxx Degrees and the L to me in xxx mm.

Thanks!

Risposte (0)

Categorie

Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by