MATLAB: If statement with an greater than comparison

if statement

Hi,
I am trying to write an "if" statement between 2 values. I have a value "A" and a value "B". I want to set C to the value of A or B that is larger.
So like if A>B then C=A, otherwise C=B.
I am having trouble getting the proper code for this in matlab though.
Thanks

Best Answer

It's pretty much what you've written:
if A > B
C = A;
else
C = B;
end