I'm trying to get Matlabs's MuPad as pretty and convenient as MathCad.
Assume two variable assignments:
x_a:=2*unit::mm;
y_b:=5*unit::mm;
and I want a prettyfied (typeset with Tex) output like
z = x_a + y_b = 7 mm
I already managed to do so by using output::mathText(...)
:
output::mathText(hold(z)," = " , (z:=hold(x_a+y_b)) , " = " , z)
which looks as desired:
But this is not really convenient and not readable. So I'm trying to wrap it into a macro or a function:
evalPrint(z,x_a+y_b)
How can I do that?
What I tried:
I wrote a procedure as follows:
evalPrint :=
proc(x,y) begin
output::mathText(hold(x)," = " , (x:=hold(y)) , " = " , x)
end_proc:
but I just get
What am I missing?
Regarding horchler's answer: his first solution does somehow not work, while the second does:
procedures:
evalPrintVal := proc(x,y) option hold;
begin
output::mathText(x, " = ", evalassign(x,y));
end_proc:
evalPrintEq := proc(x,y) option hold;
begin
output::mathText(x, " = ", evalassign(x,y), " = ", context(y));
end_proc:
evalPrintEq2 := proc(x,y) option hold;
begin
output::mathText(x, " = ", y, " = ", evalassign(x,y));
end_proc:
call:
evalPrintVal(U_1,15000*unit::V);
evalPrintEq(E_h, U_1*1.05);
evalPrintEq2(E_h, U_1*1.05);
output: