Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

use the "subs" command to subsitute equations for a variable

Asked by Philosophaie

Philosophaie (view profile)

on 20 Sep 2013

Here is a silly question: is there a way to use the "subs" command to subsitute equations for a variable?

eqn = 2*(2*x-1) + 3*(3*x+2) + 4*(4*x-5)=11
eqn1 = subs(eqn, {2*x-1,3*x+2,4*x-5}, {a,b,c}); ???

The result:

2*a+3*b+4*c=11 ???

3 Comments

Azzi Abdelmalek

Azzi Abdelmalek (view profile)

on 20 Sep 2013

What is the aim of doing this?

Philosophaie

Philosophaie (view profile)

on 20 Sep 2013

Simplify the viewing of large equation.

Walter Roberson

Walter Roberson (view profile)

on 20 Sep 2013

It makes a difference as to whether the expressions appear exactly, or if instead you want an algebraic transformation. For example if the code had 2*x-2 and you substituted 2*x-1 -> a, then would you want the result to be a-1 or would you want the substitution to be skipped ?

Philosophaie

Philosophaie (view profile)

Tags

Products

No products are associated with this question.

1 Answer

Answer by Azzi Abdelmalek

Azzi Abdelmalek (view profile)

on 20 Sep 2013
syms x a
y=2*(2*x-1);
subs(y,a)

0 Comments

Azzi Abdelmalek

Azzi Abdelmalek (view profile)

Contact us