why is the "pretty" command does not work in the script,but works when I press it in the command windo?

11 vues (au cours des 30 derniers jours)
hello I have this command
syms A D k x_0
eqn_1=A*(exp(k*x_0)-exp(-k*x_0))==D*exp(-k*x_0)
eqn_2=-k*D*exp(-k*x_0)-k*A*(exp(k*x_0)+exp(-k*x_0))==1
sol = solve([eqn_1, eqn_2], [A D ])
A=(sol.A)
D=(sol.D)
A=pretty(A)
D=pretty(D)
my question is why when the pretty comand apprers in the script it does not work but when i press the command in the command window it works ?

Réponses (1)

Stephan
Stephan le 5 Juin 2018
Hi,
try this:
syms A D k x_0
eqn_1=A*(exp(k*x_0)-exp(-k*x_0))==D*exp(-k*x_0)
eqn_2=-k*D*exp(-k*x_0)-k*A*(exp(k*x_0)+exp(-k*x_0))==1
sol = solve([eqn_1, eqn_2], [A D ])
A=(sol.A)
D=(sol.D)
pretty(A)
pretty(D)
This gives you:
A =
-exp(-k*x_0)/(2*k)
D =
-(exp(k*x_0) - exp(-k*x_0))/(2*k)
exp(-k x_0)
- -----------
2 k
exp(k x_0) - exp(-k x_0)
- ------------------------
2 k
The way you did it makes an error in both cases (command window and script):
Error using sym/pretty
Too many output arguments.
So use:
pretty(A)
pretty(D)
instead of
A = pretty(A)
D = pretty(D)
Best regards
Stephan

Catégories

En savoir plus sur Electrical Block Libraries 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