Le lundi 30 novembre 2015 à 07:25 -0800, NotSoRecentConvert a écrit :
> D = [1:10;]
> statusesValve1 =
> [false;false;true;true;true;false;true;true;true;false]
> valveLogic = "V1 == true"
>
> # Valve Zones
> f4 = []
> valveLogic = replace(valveLogic," =="," .==")
> valveLogic = replace(valveLogic,"V","statusesValve")
> valveLogic = "find(" * valveLogic * ")"
> f4 = eval(parse(valveLogic))
> f4diff = diff(f4)
> f4loc_start = [f4[1];f4[find(f4diff .!= 1) + 1]] # Start
> f4loc_end = [f4[find(f4diff .!= 1)];f4[end]] # End
>
> # Plot
> ...
>
> Let's keep it simple and plot D where statusesValve1 is true. In this
> case there are two periods where valve 1 is on, [3;4;5] and [7;8;9].
> The code above finds where each period starts (f4loc_start) and ends
> (f4loc_end). With f4loc_start and f4loc_end I have the indices of
> where the periods each start and end so I can plot the periods
> individually.
>
> Hopefully that explains it better.
It does. But what Tim suggested is a good solution.
Regards