MATLAB: Subtracting a value from a vector

matrix subtraction

Hello I have a 10*1 vector like A=[3,4,5,6,7,8,9,2,4,3]. I want to subtract all the elements of this vector by another 1*1 vector B=[5].
A-B doesn't work to give me [-2,-1,0,1,2,3,4,-1,-2]. How can I do this?

Best Answer

Maybe you mean: how to remove the element in B from A
A=[3,4,5,6,7,8,9,2,4,3]
B=3
out=setdiff(A,B)