In my code some variables are getting negative values, I want to make minimum as zero, therefore when they get negative values I want them to assign them zero value.HOW to do it?
1 次查看(过去 30 天)
显示 更早的评论
In my code some variables are getting negative values, I want to make minimum as zero, therefore when they get negative values I want them to assign them zero value.The variables are N and P. I want whenever N or P goes negative than if N or P <=0 than N or P = 0 and Gp = 0. I am unable to do so in my for loop. Need Assistance!
0 个评论
采纳的回答
Walter Roberson
2016-5-9
N = max(0, N);
4 个评论
Walter Roberson
2016-5-10
You wrote,
"I want to make minimum as zero, therefore when they get negative values I want them to assign them zero value"
Add the line N = max(0,N) at the point at which you want to make the negative numbers into 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!