if" function in matrix elements
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Roger Stafford
2014-11-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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!