I don't know if it is clear from title what I actually want to ask.
I am trying to plot rectangular pulses. I simple dont want any of the plotted pulses to overlap.
The thing is, the start times of the pulses are calculated from some program. When I find the pulses for next user then these instances are overlapping (in multiple ways) with the earlier instances. Following is the code.
users=[1 2 3 4 5 6]
WCId=[3437 68688 77158 79405]
FWCId=[34619 68928 77398 79645]
if ((NZGlobIWC(ii)-Dur) < WCId(jj)) && (WCId(jj)< (NZGlobFWC(ii)+Dur)) || ((NZGlobIWC(ii)-Dur) < FWCId(jj)) && (FWCId(jj)< (NZGlobFWC(ii)+Dur))
WCId(jj) = NZGlobFWC(ii) + Dur +randi ([240 600]);
for kk=1 :length(WCId)
One thing I found is, in overlap removal loop, I check the current instance(WCId) with Global instances(NZGlobIWC), but I dont check this newly formed instanes (modified WCId) again with the NZGlobIWC. This is what might be causing problem. I tried to use "while" loop in the Overlap removal. But it takes like forever to end the loop . As this is just a very small part of my program I need computationally efficient way to resolve this seemingly complex issue.
How can I stop overlapping of these pulses?
P.S. Attached in the expected figure .