MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Asked by Matthew
on 27 Apr 2011

I have 100 equations and 101 variables. I'm trying to find all variables as a function of one variable i.e. x = f(t); y = g(t); ......, etc. I already have all the equations on a text file in linear form (i.e. y = x + 3t, etc). I was wondering how I would be able to solve it using one of these two ways: 1) I can make a matrix of coefficents and solve it using one of Matlab's functions. However, a 100x100 matrix means I would have to input 1,000 cells. The possibility of human error is quite high. Is there any function that allows me to translate my already made equations into a matrix of coefficents? 2) About 80 of the equations are 3 variable equations (i.e. x = 10y - 6z), isn't there anything in the symbolic toolbox that allows me to simply start solving them as a function of t without having to go through annoying matrix methods?

*No products are associated with this question.*

Answer by Walter Roberson
on 27 Apr 2011

You can use sym2poly to extract expressions.

To solve as functions of t, use subs() to convert your plain x and y and so on in to x(t), y(t) and so on. Then use solve() or dsolve()

Matthew
on 27 Apr 2011

While the sym2poly definitely can speed up the process, Matlab says that it can't have more than one input variable. Therefore, to use it I would have to rearrange all 100 equations so they only have 1 input variable. That's harder than just manually inputting all 10,000 coefficents.

The subs function seems promising, but its a bit more intensive. I'll comment when I figure out how to implement it best.

## 0 Comments