printing complete mathematical equation

51 vues (au cours des 30 derniers jours)
ali mohseni
ali mohseni le 16 Déc 2022
Commenté : Walter Roberson le 18 Déc 2022
Hello All,
I am working with symbolic functions in live editor mode. What I want to do is that as I am calculating a function, I want the mathematical equation to be completely shown. I mean the right hand side of the equation be printed and left hand side will be calcualated and then printed.
syms m(t) n(t)
A=10*cos(m)+5*sin(n)
A(t) = 
diff(A,t)
ans(t) = 
for example, for above equation I want it to be shown as:
Is there a way to do this?

Réponses (2)

Torsten
Torsten le 16 Déc 2022
syms m(t) n(t) A(t)
eqn = A==10*cos(m)+5*sin(n)
eqn(t) = 
deqn = diff(eqn,t)
deqn(t) = 
  4 commentaires
ali mohseni
ali mohseni le 16 Déc 2022
Modifié(e) : ali mohseni le 16 Déc 2022
I just tried this. I faced two problems which are:
  • The RHS for the display formula could not be empty:
S = "m*diff(y,t,t) == m*g-k*y";
displayFormula(S)
S = "m*diff(y,t,t)=";
%displayFormula(S)
%Just uncomment the above command and you'll see the error.
  • Second as I defined L before, when I put L in the displayFormula command it just plugs in what I have defined for L.
syms M K X(t) L(t)
L = M*diff(X,t)^2/2+K*X^2
L(t) = 
S = "m*diff(L,X)=1"
S = "m*diff(L,X)=1"
displayFormula(S)
Do you know how I can solve these problems?
Walter Roberson
Walter Roberson le 16 Déc 2022
syms M K X(t) L(t)
L = M*diff(X,t)^2/2+K*X^2
L(t) = 
S = "m*diff(L,X)=1"
S = "m*diff(L,X)=1"
displayFormula(S, sym([]), sym([])) %no substitutions

Connectez-vous pour commenter.


Torsten
Torsten le 16 Déc 2022
I don't know exactly what you mean.
syms M K X(t) %Physical Parameters
dX = diff(X,t);
L= M*dX^2/2+K*X^2
L(t) = 
A1 = diff(L,dX)
A1(t) = 
A2 = diff(diff(L,X),t)
A2(t) = 
A3 = diff(L,X)
A3(t) = 
  3 commentaires
Torsten
Torsten le 17 Déc 2022
Modifié(e) : Torsten le 17 Déc 2022
Not possible.
Use LaTex to write mathematical formulae in a text editor.
Walter Roberson
Walter Roberson le 18 Déc 2022
You can create forms. It might take more work to get them pretty.
syms M X(t)
RHS = M*diff(diff(X(t),t),t);
S = "diff(diff(L,diff(X(t),t)),t) = RHS"
S = "diff(diff(L,diff(X(t),t)),t) = RHS"
displayFormula(S, sym('RHS'), RHS)

Connectez-vous pour commenter.

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by