Borrar filtros
Borrar filtros

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

4 visualizaciones (últimos 30 días)
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 ?

Respuestas (1)

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

Categorías

Más información sobre Electrical Block Libraries en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by