How to set continue function?
6 次查看(过去 30 天)
显示 更早的评论
What the function that i need to set code-step which will decide wheter my coding continue to run or stop.
i want create a code after rows named 'checkperiod'. If the result of checkperiod is true(1), i want it to stop my running code and send me a message "Make the structure bigger" and this message can be string-variable. If the resut of checkperiod is false(0), then let it continue but still send me the message by string variable that contains "fullfill".
Thank for attention
1 个评论
Dyuman Joshi
2024-2-13
编辑:Dyuman Joshi
2024-2-13
The use of logical() in line 157 is redudant. You can remove it.
采纳的回答
Aquatris
2024-2-13
You are looking for assert() function.
When you condition is satsified
assert(1>0,'STOPPED THE CODE!')
fprintf('Code continues!')
When your condition is not satisfied;
assert(1<0,'STOPPED THE CODE!')
fprintf('Code continues!')
4 个评论
Aquatris
2024-2-13
assert function stops the code, thats why you do not see the 'Code continues!' text when the assert condition is false.
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!