If statement with an greater than comparison

조회 수: 113 (최근 30일)
James
James 2014년 10월 6일
댓글: José-Luis 2014년 10월 6일
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

채택된 답변

Guillaume
Guillaume 2014년 10월 6일
It's pretty much what you've written:
if A > B
C = A;
else
C = B;
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by