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
Dyuman Joshi 2024년 2월 13일
편집: Dyuman Joshi 2024년 2월 13일
The use of logical() in line 157 is redudant. You can remove it.
Also, you can use deal to assign (the same) inputs to different outputs.

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

 채택된 답변

Aquatris
Aquatris 2024년 2월 13일

0 개 추천

You are looking for assert() function.
When you condition is satsified
assert(1>0,'STOPPED THE CODE!')
fprintf('Code continues!')
Code continues!
When your condition is not satisfied;
assert(1<0,'STOPPED THE CODE!')
Error using assert
STOPPED THE CODE!
fprintf('Code continues!')

댓글 수: 4

Arif
Arif 2024년 2월 13일
Will the function let my code stop/continue? It seems only give a warning message
Steven Lord
Steven Lord 2024년 2월 13일
The warning function issues warnings that will not stop execution of your code.
The assert function and the error function throw errors that will stop execution if they are not caught by a try / catch block.
If this occurs inside a loop, you may also be interested in the break and continue keywords. break ends the loop and moves on to the next statement after the end that ends the loop. continue skips the rest of the current iteration and moves back to the start of the next loop iteration.
Aquatris
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.
Arif
Arif 2024년 2월 14일
thanks

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

추가 답변 (1개)

Fangjun Jiang
Fangjun Jiang 2024년 2월 13일

1 개 추천

doc continue
doc break

카테고리

도움말 센터File Exchange에서 Clocks and Timers에 대해 자세히 알아보기

제품

질문:

2024년 2월 13일

댓글:

2024년 2월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by