MATLAB: Change element of vector to zero based on start and finish matrix

change valuezero

I have a vector, A = [1:50].
I also have a matrix for starts and ends of events (element number start to element number finish);
if true
B = [ start_of_event_1 end_of_event_1
start_of_event_2 end_of_event_2 ]
end
This goes on for ~200 events. I want to change the elements of the vector between these points to zero. I am not sure how to go about this. I have tried:
if true
A(B(:,1):B(:,2)) = 0;
end
This has not worked so far.
Background: zero-ing is needed rather than removing values altogether for further analysis (time domain needs to stay).

Best Answer

Realized the solution as just looping it. I feel a bit silly, but I will leave this here in case somebody runs into a similar issue.
for n=1:length(A)
A(B(n,1):B(n,2) = 0;
end