Skip to main content
gamedev.net
🔒 Locked

MATLAB

Started by deshapoui 6 replies 950+ views
Original Post
deshapoui
deshapoui
Does anyone knows how to use the "solve" in MATLAB? A simple example will be welcome. Thanks in advance.
Sneftel
Sneftel
What's wrong with the examples you get by typing "help solve"?
_Sigma
_Sigma
Quote:
The Symbolic Math package, included in the Student Edition of Matlab, allows us to easily do symbolic manipulations on equations, such as factoring, solving, root finding, integrating, differentiating and solving differential equations.

1. For all variables in the Symbolic Math Package, use single lower case letters (a,b,c,...z) and not upper case letters, numbers or multicharacter strings. The package sometimes has problems parsing strings with more complicated variable names.
2. To define a mathematical function, put quotes around it, such as: 'a*x^2 + b*x + c=0' or 'p*v = n*r*t'
3. You can store a function in a character string, such as QuadEqn = 'a*x^2 + b*x + c=0'
4. The solve command will find the solution (either symbolic or numeric) for a single equation or a system of equations. Try some of the examples below:
* solve(QuadEqn,'x') % This will solve symbolically for the variable x
* solve(QuadEqn,'a=3','c=-1','x=-1') % will find the value of b which makes this true
* solve(QuadEqn,'a=sqrt(c)','b=2','x=-1') % A more complicated example
* solve('y=m*x+b','y=n*x+c','m=1','b=2','n=3','c=4') % Will find intersection of two lines
* solve('y=sin(log(x+y))','y=cos(exp(x^y))') % Try this one on your calculator!
5. To quickly plot some equation with a single variable over some range, use ezplot
* ezplot('sin(x)/x',[-10 9.9]) % (I used 9.9 so it wouldn't evaluate it at zero, which gives a divide by zero error)
* ezplot('sin(x)^3+x+sin(x)', [-20 20])
6. For a complete discussion, see the "Symbolic Math Toolbox Tutorial" in the Student Edition of Matlab manual.

From here.
Ravuya
Ravuya
I thought homework help was verboten.
Chokki
Chokki
Quote:
Original post by Ravuya
I thought homework help was verboten.
Is showing how to use a program helping that person with their homework, though?

Quote: Original post by EtnuBwahaha. I would've shot the guy in the balls.
_Sigma
_Sigma
Quote:
Original post by Chokki
Quote:
Original post by Ravuya
I thought homework help was verboten.
Is showing how to use a program helping that person with their homework, though?

I wouldn't think so.

It's kinda funny, their first post is about MATLAB in the OT Lounge :P
deshapoui
deshapoui

Thanks a lot, _Sigma for your help. I'm just a starter at MATLAB and you really helped me understand many things. Thanks one more time.
_Sigma
_Sigma
Quote:
Original post by deshapoui

Thanks a lot, _Sigma for your help. I'm just a starter at MATLAB and you really helped me understand many things. Thanks one more time.


NO worries. Perhaps check google next time, as that is where I obtained said information. Glad I could help though.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.