please help, i got quesion of matrix and if condition.
If G=any matrix with two columns.
if one of the numbers in G is equal or less than 1,
C=A+B
elseif if two of the numbers in G is equal or less than 1,
C=A-B.
How to create this condition?
please help. any help will be appreciated.
Thanks Jagadesh Rao Thalur

 채택된 답변

Roger Stafford
Roger Stafford 2014년 11월 2일

2 개 추천

s = sum(G(:)<=1);
if s == 1
C = A+B
elseif s == 2
C = A-B
else
??? What do you want to happen if either none or else more than two have this property?
end

댓글 수: 1

Jagadesh Rao
Jagadesh Rao 2014년 11월 2일
Thankyou so much. Roger Stafford
i'll fill the else in the end.
see you again.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2014년 11월 2일

댓글:

2014년 11월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by