Clear Filters
Clear Filters

Problem with syms and subs continues to display the subbed expressions as variables.

1 view (last 30 days)
Everytime I try to run this is just returns the variable isolation. It's not giving me values. I can't figure out what's going wrong? Help!
D1 = 1;
D2 = 40;
D3 = 10;
D4 = 70;
Weight1 = 100;
Weight2 = 0;
AllVariables = [D1 D2 D3 D4 Weight1 Weight2];
syms Pug1 Pug2
Set1 = sym('(D1 + D3) * Pug1 - D3 * Pug2 = Weight1');
Set2 = sym('-D3 * Pug1 + (D2 + D3 + D4) * Pug2 = Weight2');
[Pug1,Pug2] = solve(Set1,Set2)
P_1 = double(subs(Pug1,[sym('D1'),sym('D2'),sym('D3'),sym('D4')],AllVariables))
P_2 = double(subs(Pug2,[sym('D1'),sym('D2'),sym('D3'),sym('D4')],AllVariables))
  1 Comment
Stephen23
Stephen23 on 26 Feb 2017
@Anas Deiranieh's: this time I formatted your code for you. Next time you can do it yourself by selecting the code text and clicking the {} Code button above the textbox.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 26 Feb 2017
D1 = 1;
D2 = 40;
D3 = 10;
D4 = 70;
Weight1 = 100;
Weight2 = 0;
syms Pug1 Pug2
Set1 = (D1 + D3) * Pug1 - D3 * Pug2 == Weight1;
Set2 = -D3 * Pug1 + (D2 + D3 + D4) * Pug2 == Weight2;
[Pug1,Pug2] = solve(Set1,Set2)

More Answers (0)

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!