Effacer les filtres
Effacer les filtres

How to substitute to a variable in a function with a constant

2 vues (au cours des 30 derniers jours)
ijsonvjksrefdsb
ijsonvjksrefdsb le 6 Sep 2022
Modifié(e) : Stephen23 le 18 Oct 2022
I'm trying to substitute some values of t to this equation:
x = 3.0 + 4.0.*t + c.*t.^2 - 2.0.*t.^3;
Unrecognized function or variable 't'.
But it won't work because of the c. The assignment is to avoid using symbolic math, how can I bypass this error? Like it would simply substitute the values of t with c remaining undefined. Thanks
  1 commentaire
Stephen23
Stephen23 le 18 Oct 2022
Modifié(e) : Stephen23 le 18 Oct 2022
Original question retrieved from Google Cache:
How to substitute to a variable in a function with a constant
I'm trying to substitute some values of t to this equation:
x = 3.0 + 4.0.*t + c.*t.^2 - 2.0.*t.^3;
Unrecognized function or variable 't'.
But it won't work because of the c. The assignment is to avoid using symbolic math, how can I bypass this error? Like it would simply substitute the values of t with c remaining undefined. Thanks

Connectez-vous pour commenter.

Réponses (1)

Chunru
Chunru le 6 Sep 2022
Modifié(e) : Chunru le 6 Sep 2022
% Specify the values beforehand
t = 0:.1:5;
c = 2;
x = 3.0 + 4.0.*t + c.*t.^2 - 2.0.*t.^3;
plot(t, x)
% symbolic computation
syms t c x
x = 3.0 + 4.0.*t + c.*t.^2 - 2.0.*t.^3
x = 
  2 commentaires
ijsonvjksrefdsb
ijsonvjksrefdsb le 6 Sep 2022
c can't be defined...
Chunru
Chunru le 6 Sep 2022
Do you want to have symbolic computation?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by