I think this does what you want:
Price = randi(10,20,1)
buy = [true;diff(Price)>=0];
idx = find(~diff(Price));
buy(idx+1) = buy(idx);
[Price,buy]
I'm using a logical array buy that is true for "buy" and false for "sell". You could use a nominal array (if you have Statistics Toolbox) to assign arbitrary labels (ie "buy" and "sell"), but logical probably does what you want the easiest.
EDIT: if you really want a column of strings (for output purposes), this will do it:
buysell = cellstr(repmat('Sell',size(Price)));
buysell(buy) = {'Buy'}
Best Answer