# Solve MATLAB Equation Problem w/ Long Number Answer

• MATLAB
• Wasper
In summary, the conversation involves a person looking for help with solving a system of equations using MATLAB. They have provided the equations and their attempted code, but are struggling to get a numerical answer. They also mention the possibility of using Maple. The equations appear to be related to a system under investigation, possibly in robotics. The person also asks for help with plotting an equation.
Wasper
Hello, I am trying to solve the following system of equations simultaneously with matlab:

0=(.3*cos(B)*cos(P)*cos(60))+(.2*sin(60))-(.3*sin(B)*sin(60))+S
0=(.3*cos(B)*sin(P))-.15
0=(.2*cos(60))-(.3*cos(B)*cos(P)*sin(60))-(.3*sin(B)*cos(60))

Unknowns are B, P, and S.

I have tried the following code which yields an answer:

syms B P S;

[B,P,S] = solve((.3*cos(B)*cos(P)*cos(pi/3))+(.2*sin(pi/3))-(.3*sin(B)*sin(pi/3))+S, (.3*cos(B)*sin(P))-.15, (.2*cos(pi/3))-(.3*cos(B)*cos(P)*sin(pi/3))-(.3*sin(B)*cos(pi/3)));

// note that the above is in one single line.
Unfortunately the answer is given to me in the form of another equation with extremely long numbers. I need MATLAB to give me an answer in the form of one number, how can this be done?

If all else fails I heard that this can be easily done in Maple, but I have no idea how to use it.

Never mind, one my friends figured it out, you just use the eval command to get a numerical answer. i.e. eval(B) to get B.

Just out of curiosity, where does these equations come from? Robotics? I mean what is your system that is under investigation.

x2/a2+y2/b2+z2/c2=1
how to plot this equation?
help me

## What is MATLAB?

MATLAB (MATrix LABoratory) is a high-level programming language and interactive environment used for numerical computation, visualization, and programming. It is widely used in engineering, science, and mathematics fields.

## How do I solve an equation in MATLAB?

To solve an equation in MATLAB, you can use the solve function. This function takes in the equation as a string and the variable you want to solve for, and returns the solution as a symbolic expression. For example, syms x y; solve('3*x + 2*y = 10', 'x') will solve the equation 3x + 2y = 10 for x.

## What if my equation has a long number answer?

MATLAB can handle long numbers without any issues. However, when displaying the answer, it may be shown in scientific notation. To change this, you can use the format function. For example, format longg; solve('2*x + 3*y = 123456789', 'y') will solve the equation and display the answer in long format without scientific notation.

## Can I solve multiple equations at once in MATLAB?

Yes, MATLAB can solve multiple equations at once using the syms and solve functions. You can define multiple variables using the syms function and then use the solve function to solve the equations simultaneously. For example, syms x y z; solve('2*x + 3*y = 10', '3*x + z = 20', '2*y + 4*z = 30') will solve these three equations for x, y, and z.

## Is there a way to check my solution in MATLAB?

Yes, you can use the subs function to substitute the solved values back into the original equation and check if it equals to the other side of the equation. For example, subs(3*x + 2*y, x, 4) will substitute x = 4 into the equation 3x + 2y and return the value 12 + 2y. You can compare this with the other side of the equation to check if your solution is correct.

• MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
922
• MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
646
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
• Precalculus Mathematics Homework Help
Replies
14
Views
411
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
• Calculus and Beyond Homework Help
Replies
1
Views
309
• MATLAB, Maple, Mathematica, LaTeX
Replies
19
Views
225
• Precalculus Mathematics Homework Help
Replies
7
Views
663