Solve MATLAB Equation Problem w/ Long Number Answer

  • Context: MATLAB 
  • Thread starter Thread starter Wasper
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary

Discussion Overview

The discussion revolves around solving a system of equations using MATLAB, specifically focusing on obtaining numerical solutions from symbolic expressions. The context includes technical aspects of programming in MATLAB and potential alternatives like Maple.

Discussion Character

  • Technical explanation
  • Homework-related

Main Points Raised

  • One participant presents a system of equations involving variables B, P, and S, and shares their MATLAB code for solving it.
  • The same participant expresses frustration with receiving a long numerical expression instead of a simple numerical answer.
  • Another participant suggests using the eval command in MATLAB to convert symbolic results into numerical values.
  • A third participant inquires about the origin of the equations, speculating whether they relate to robotics or another system.
  • A separate participant introduces a different equation related to plotting, seeking assistance without connection to the original MATLAB problem.

Areas of Agreement / Disagreement

There is no consensus on the origin of the equations, and the discussion about the MATLAB problem is resolved with a proposed solution. However, the introduction of a new equation for plotting indicates a shift in focus and introduces a separate topic.

Contextual Notes

The discussion does not clarify the specific context or application of the original equations, nor does it resolve the implications of using eval in MATLAB. The new equation introduced by another participant is unrelated to the original topic.

Who May Find This Useful

Participants interested in MATLAB programming, numerical solutions of equations, and those exploring mathematical modeling in robotics or related fields may find this discussion relevant.

Wasper
Messages
6
Reaction score
0
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.

Thanks in advance.
 
Physics news on Phys.org
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
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K