MATLAB: Finding a median of a matrix in form of a matrix

MATLABmedian

How could I turn a vector such as: [0 0 1 1 1 0 0]
Into: [0 0 0 1 0 0 0]
The actual matrix im dealing with is about 100×300 so I'd need something that I could maybe put into a 'for' loop in order to do all columns one-by-one.
Thank you in advance!
Edit:
My current code, until a better solution comes along, is:
s = size(graph);
for column = 1:s(2)
I = find(graph(:,column) == 1);
if I>0
place = median(I);
place = round(place);
graph(:,column) = 0;
graph(place,column) = 1;
end
end
I'm sure it's really not the best way to do it, I put it in place just for the moment so I can continue with the project.

Best Answer

Try the attached code.
0000 Screenshot.png