Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

The sample() function gives random samples?!!

The sample() function gives random samples?!!

Hi,
I tried out the sample function and it do not sample as it should. Am I doing something wrong or is it a bug? Her is the code:
-----------------------------------------
model Sampling
discrete Real r;
equation
when sample(0,0.5) then
r = pre(r)+1.0;
end when;
end Sampling;
-----------------------------------------

https://picasaweb.google.com/lh/photo/k … directlink

When I run this it does not always trigger the sample event. It is solved with:

simulate(Sampling, startTime=0, stopTime=30, numberOfIntervals=500, tolerance=1e-6, method="dassl", outputFormat="mat");

I run version 1-7.0 r8273


Great work with Open Modelica, thanks a lot!

-Jonas

<table style="width:auto;"><tr><td><a href="https://picasaweb.google.com/lh/photo/kVf3cOnAmcx6yxzdWcalSA?feat=embedwebsite"><img src="https://lh3.googleusercontent.com/_NBBs172I_oU/TYTz9E3CKDI/AAAAAAAABag/PXSqYO2i0hE/s144/stumbling_stair_sampling.png" height="57" width="144" /></a></td></tr><tr><td style="font-family:arial,sans-serif; font-size:11px; text-align:right">From <a href="https://picasaweb.google.com/jonas.malmqvist/Mar192011?feat=embedwebsite">Mar 19, 2011</a></td></tr></table>

Re: The sample() function gives random samples?!!

Hi again, tried it out with r8226-1 and that worked better.... Now it looks as it should.
Cheers,
-Jonas

There are 0 guests and 0 other users also viewing this topic
You are here: