why is the "pretty" command does not work in the script,but works when I press it in the command windo?
조회 수: 10 (최근 30일)
이전 댓글 표시
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 ?
댓글 수: 0
답변 (1개)
Stephan
2018년 6월 5일
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
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!