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 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Walter Roberson
le 24 Avr 2020
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 commentaires
Walter Roberson
le 26 Avr 2020
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.
Voir également
Catégories
En savoir plus sur Calculus dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!