Sauberschrauber

30 Reputation

3 Badges

1 years, 55 days

MaplePrimes Activity


These are questions asked by Sauberschrauber

Dear Forum, 

 

I want to make a Document where some values are initialised and left alone afterwards.
The startup-code seems to be the solution. The manual says, it is executed, when the document is reloaded.

But if i execute the document with "!!!" the startup-code is executed too. 
How can I avoid this ? 
Is there a good way to write "run once" code ?

 

Thank you very much

 

Klaus

startup code is  : 

init:=false;

After reloading, this should be false  init = trueNULL

the startup code should be executed after reloading but is executed when the code is executed with !!! . init is set to false again
If the code is executed stepwise , ! by ! , it behaves as expected.

if not init then x := 3; y := 4; init := true end if
 

2*x = 8NULL

x := 4

4

(1)

2*x = 8NULL

NULL

NULL

NULL


 

Download doesnotrunonce.mw

Dear forum,

my name is Klaus, I am a former mathcad-user and new to maple. I try to get some sheets converted and found a maple-behaviour I don't understand.

I made up a simple function with an if statement. When I try different inputs by hand, I get correct results.
But if I try to plot it, I get the message that the if-statement does not work.

My question : How can I solve this ? And what is the difference between plotting a function and entering values manually ?

restart;
with(Units[Simple]);

funktion := x -> if 2*Unit('m') < x then 1/x; else 2*Unit('m'); end if;

r1 := 3.0*Unit('m');

r2 := 6*Unit('m');

plot(funktion(x), x = r1 .. r2);
Error, (in funktion) cannot determine if this expression is true or false: 2 < x*Units:-Unit(1/m)

Page 1 of 1