フィルターのクリア

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

1 回表示 (過去 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 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 4 月 24 日
Are these equations defined using symbolic variables?
Elliott Cameron
Elliott Cameron 2020 年 4 月 24 日
variables are x=0:0.02:1
y=0.5*x +2

サインインしてコメントする。

回答 (1 件)

Walter Roberson
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 件のコメント
Elliott Cameron
Elliott Cameron 2020 年 4 月 26 日
brillaint thank you so much, one last question if i wanted to make the disp(eqn1_new) into a new equation known as p?
Walter Roberson
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 ExchangeNumber Theory についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by