MATLAB: IF argument question I am seriously new to coding.

if statement

Ok, Im trying to output c1 for x from 0 to 10. Im looking for it to return c1=0 0 0 0 0 0 0 0 1 2 but it keeps giving me c1=-8 -7 -6 -5 -4 -3 -2 -1 0 1 2
if the function c is less than zero I am trying to tell it to make c1=0, and if c is greater than zero to make c1 whatever c would be.
function beam_displac(x)
L=0:x
c=(L-8)
if c <= 0
c1= 0
else c1=c
end
What am I doing wrong? How might I do this? Thanks

Best Answer

You mean like this:
c1 = max(0,x-8)
???