Hello, if i have two equations 1)2x+2 and 2)3x^2+ 4x-7 is there a way to remove the x in a new equation where i am left with 1)2+2 2)3^2+4-7? i would hope it would work with any equation with x in
2 ビュー (過去 30 日間)
古いコメントを表示
Hello, if i have two equations 1)2x+2 and 2)3x^2+ 4x-7 is there a way to remove the x in a new equation where i am left with 1)2+2 2)3^2+4-7? i would hope it would work with any equation with x in
2 件のコメント
回答 (1 件)
Walter Roberson
2020 年 4 月 24 日
syms x
eqn2 = 3*x^2 + 4*x - 7
subs(eqn2, x, 1)
Or numerically instead of symbolically:
eqn2 = @(x) 3*x.^2 + 4*x - 7;
eqn2(1)
14 件のコメント
Walter Roberson
2020 年 4 月 26 日
The '' are not part of eqn1_new, they are decoration that MATLAB adds when you display a variable by just giving the name of the variable. disp() is not changing the value, it is just not adding the decoration as it displays the data.
Because of this, although you could
p = evalc('disp(eqn1_new)');
to in some sense capture the display without the '', then as soon as you went to display p just by mentioning its name, MATLAB would add the '' decoration to that -- and you would also have accidentally captured the newline that disp() added. You are no further ahead than if you had just done
p = eqn1_new;
Do not confuse the content of eqn1_new with the decoration that MATLAB adds when displaying it.
参考
カテゴリ
Help Center および File Exchange で Calculus についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!