Matlab by default deals with matrices. When you include ^2, it means matrix squaring which can be performed only for a square matrix. As you are dealing with vectors, use .^2 as you have done for all multiplications and divisions. Just the last w^2 is wrong here.
BTW a better way to plot bode would be to use tf and use bode command.