How to separate an equation into several equations?

5 views (last 30 days)
Hi there,
If I have an equation in Matlab for example in the form f(x)=(x+1)(2x+4), how can I seperate it into two equations of the following forms: g(x)=(x+1), h(x)=(2x+4). Your help would be much appreciated.
Thank you.

Accepted Answer

Image Analyst
Image Analyst on 8 Jun 2014
Help with what? What do you want? two functions, or two array? For array, do this
fx = (x+1) .* (2*x+4);
hx = 2*x+4;
gx = x+1;
fx = gx .* hx; % Version using gx and hx.
For functions you just do
function out = g(x)
out = x+1;
function out = h(x)
out = 2 * x + 4;
If that's not what you want, then explain better.
  2 Comments
Ramy
Ramy on 8 Jun 2014
I'm sorry for my bad explanation. What I meant is that I don't know what these functions are. For example it could be f=(x+1)(x-2) or f=(2x+1)(x-4). It could be any combination of functions.
To put it better, is there any way in matlab to separate parts of a big equation to smaller equations?
Image Analyst
Image Analyst on 8 Jun 2014
Well you have to know what the original function is. But, are you asking how to symbolically factorize an nth order polynomial into a polynomial of x and a polynomial of order (n-1)? Or into a whole bunch of lower order polynomials? I don't know how to do that, but I'll add tags so that maybe someone else will answer.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!