How to get If Then statements to work on a vector
1 次查看(过去 30 天)
显示 更早的评论
Hi. (Relatively) new to Matlab.
I try this code
x=[4 5 6]
if x>5
y=5
else
y=x
end
expecting y to return y=4 5 5
but instead it returns y= 4 5 6
What am I doing wrong with this IF statement? How can I do elementwise logical statements? I have searched for this but have found nothing helpful.
Thanks
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!