Problem with symbolic math

10 ビュー (過去 30 日間)
Amit Kumar
Amit Kumar 2013 年 10 月 21 日
回答済み: Azzi Abdelmalek 2013 年 10 月 21 日
Hello, I am trying hard to get code running, however I am stuck at a place. Please help me.
I have declared 3 symbolic variables x1,x2,x3. gr is a column vector and function of x1,x2,x3. p1 is a column vector of constants. I want to substitute values of x2,x2,x3 by first, second, and row of p1. That is x1 = 957/2500, x2=-293/1250, etc. And I want to make it as a new vector gr2. MATLAB is giving errors of inconsistent dimensions. Please help! Thanks
syms x1 x2 x3
gr =
2*x1 + 2*x2
2*x1 + 4*x2 + 2*x3
2*x2 + 4*x3
p1 =
957/2500
-293/1250
371/5000
gr2=subs(gr,[x1,x2,x3],[p1(1),p1(2),p1(3)]);

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 10 月 21 日
syms x1 x2 x3
gr =[2*x1 + 2*x2;2*x1 + 4*x2 + 2*x3; 2*x2 + 4*x3]
p1 =[957/2500;-293/1250;371/5000];
gr2=subs(gr,{x1,x2,x3},{p1(1),p1(2),p1(3)})

その他の回答 (1 件)

sixwwwwww
sixwwwwww 2013 年 10 月 21 日
編集済み: sixwwwwww 2013 年 10 月 21 日
Dear Amit, it is working fine:
syms x1 x2 x3
gr = [2*x1 + 2*x2; 2*x1 + 4*x2 + 2*x3; 2*x2 + 4*x3];
p1 = [957/2500; -293/1250; 371/5000];
gr2 = subs(gr,[x1,x2,x3],[p1(1),p1(2),p1(3)]);
Can further explain your problem?

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by