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

Reply via email to