Re: [Scilab-users] automatic traverse question

2017-05-11 Thread Erhy
much learned - thank you
Erhy



--
View this message in context: 
http://mailinglists.scilab.org/automatic-traverse-question-tp4036327p4036371.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at 
Nabble.com.
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Avoiding a loop

2017-05-11 Thread Tim Wescott
Depending on how often you switch between battery and generator, and
how icky-picky you're willing to be, there may be a way to reduce
computation.

It looks like the term P(n,2) * (P(n+1,1) - P(n,1)) is always there,
and you're either adding it to 'gen' (is it energy production?) or
subtracting it from 'batt'.

If you really want to go there, you can vectorize "if" statements by
using boolean expressions on vectors and the "find" function, which
returns indexes of true results.  Then you can use "cumsum" on your
P(n,2) * (P(n+1,1) - P(n,1)) term to find where the battery state of
charge (I assume that's what 'batt' is) hits 800.

It'll be complicated.  It'll be prone to error.  Proving that it's
correct will be a pain.  But when you get it working, it'll be
considerably faster.

On Thu, 2017-05-11 at 09:17 +0200, Frieder Nikolaisen wrote:
> Thanks for all the answers. 
> 
> I feared that there is no way around a loop. During the process batt
> (Battery) is charged and discharged. In my example, it is only
> discharged. I will code the entire problem with a loop, maybe
> somebody knows something to speed up the process with the full
> problem. (Tim: I am not a programming pro, a C-function might not be
> a solution. )
> Why do I try avoidng a loop? I do have txt-document with 50 000 to
> 100 000 lines about a (hybrid-)locomotive shunting process. I do need
> to optimize the energy managment. Because I am not mathemtic student,
> I have to solve the problem empirical (try and error). The programm
> has to run a few hundred times. With a matrix thats no problem, but
> with matrixes only, I can only calculate the diesel usage without any
> battery energy storage. 
> Thanks for the checking my code anyway. 
> 
> Am 10.05.2017 um 20:53 schrieb Amanda Osvaldo:
> > What it's the equation you need to compute ?
> > Perhaps I can help.
> > 
> > I think it's possible to compute with something in this way:
> > 
> > map = find (P(:,2) > 100 );
> > if batt > 800 then
> > batt = batt - P(map,2) * (P(map+1,1) - P(map,1));
> > end
> > 
> > 
> > On Wed, 2017-05-10 at 17:23 +0200, Frieder Nikolaisen wrote:
> > > Hello,
> > > I did write an example code, but I do not like the time consuming
> > > way I solved the problem. With 50 000 lines in the matrix, it
> > > wouldn't be fun.
> > > How can I avoid using the for-loop?
> > > 10, 80;
> > > 11, 200
> > > 15, 0];
> > > 
> > > batt = 1000;
> > > gen = 0;
> > > 
> > > n = 1
> > > for n=1:5
> > > 
> > > if P(n,2) > 100 then
> > > if batt > 800 then batt = batt - P(n,2) * (P(n+1,1) -
> > > P(n,1))
> > > else
> > > gen = gen + P(n,2) * (P(n+1,1) - P(n,1))
> > > end
> > > 
> > > else
> > > batt = batt - P(n,2) * (P(n+1,1) - P(n,1))
> > > end
> > > disp('n ' + string(n))
> > > disp('batt ' + string(batt))
> > > disp('gen ' + string(gen))
> > > end
> > > Thanks alot!
> > > 
> > > Best regards
> > > Frieder 
> > >  
> > > ___
> > > users mailing list
> > > users@lists.scilab.org
> > > http://lists.scilab.org/mailman/listinfo/users
> >  
> > ___
> > users mailing list
> > users@lists.scilab.org
> > http://lists.scilab.org/mailman/listinfo/users
>  
> ___
> users mailing list
> users@lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
-- 

Tim Wescott
www.wescottdesign.com
Control & Communications systems, circuit & software design.
Phone: 503.631.7815
Cell:  503.349.8432



___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] automatic traverse question

2017-05-11 Thread Erhy
another question

gray=rand(200,300);
lumimins=[ 0.1, 0.5, 0.7, 0.9 ];
// doesn't work*:*
monos(:,:,1..length(lumimins)) = ( gray(:,:) >= lumimins(1:$) ) .* 1;

is there a way to generate 
a plane for each lumimins with automatic traverse?




--
View this message in context: 
http://mailinglists.scilab.org/automatic-traverse-question-tp4036327p4036368.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at 
Nabble.com.
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Rép : Problems with figures in Scilab 6.0.0

2017-05-11 Thread Philippe Dérogis
Hi Samuel,

  Find in here  https://we.tl/QIICI7f19C  a capture 
of the figure window with scilab 6.0. I tried to reinstall scilab 5.5 in order 
to provide you with the capture of the same figure generated with scilab 5.5 
but it doesn’t worked. I remember that at some point I had to do a strange 
things such as overwriting some system libraries in order to have scilab 
working (I founded the fix on the internet) but I didn’t remember what. So 
unfortunately the capture of the 6.0 figure is the only thing that I can give 
you.

Thanks for your help.

Philippe.


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Avoiding a loop

2017-05-11 Thread Frieder Nikolaisen

Thanks for all the answers.


I feared that there is no way around a loop. During the process batt 
(Battery) is charged and discharged. In my example, it is only 
discharged. I will code the entire problem with a loop, maybe somebody 
knows something to speed up the process with the full problem. (Tim: I 
am not a programming pro, a C-function might not be a solution. )
Why do I try avoidng a loop? I do have txt-document with 50 000 to 100 
000 lines about a (hybrid-)locomotive shunting process. I do need to 
optimize the energy managment. Because I am not mathemtic student, I 
have to solve the problem empirical (try and error). The programm has to 
run a few hundred times. With a matrix thats no problem, but with 
matrixes only, I can only calculate the diesel usage without any battery 
energy storage.


Thanks for the checking my code anyway.


Am 10.05.2017 um 20:53 schrieb Amanda Osvaldo:

What it's the equation you need to compute ?
Perhaps I can help.

I think it's possible to compute with something in this way:
map  =  find  (P(:,2)  >  100  );
if  batt  >  800  then
 batt  =  batt  -  P(map,2)  *  (P(map+1,1)  -  P(map,1));
end
On Wed, 2017-05-10 at 17:23 +0200, Frieder Nikolaisen wrote:


Hello,

I did write an example code, but I do not like the time consuming way 
I solved the problem. With 50 000 lines in the matrix, it wouldn't be 
fun.


How can I avoid using the for-loop?

10,  80;
11,  200
15,  0];

batt  =  1000;
gen  =  0;

n  =  1
for  n=1:5

 if  P(n,2)  >  100  then
 if  batt  >  800  then  batt  =  batt  -  P(n,2)  *  (P(n+1,1)  -  
P(n,1))
 else
 gen  =  gen  +  P(n,2)  *  (P(n+1,1)  -  P(n,1))
 end
 
 else

 batt  =  batt  -  P(n,2)  *  (P(n+1,1)  -  P(n,1))
 end
disp('n '  +  string(n))
disp('batt '  +  string(batt))
disp('gen '  +  string(gen))
end

Thanks alot!

Best regards Frieder
___
users mailing list
users@lists.scilab.org 
http://lists.scilab.org/mailman/listinfo/users



___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users