Filter löschen
Filter löschen

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

4 Ansichten (letzte 30 Tage)
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 ?

Antworten (1)

Stephan
Stephan am 5 Jun. 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

Kategorien

Mehr zu Electrical Block Libraries finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by