フィルターのクリア

Running program from the middle of the script

22 ビュー (過去 30 日間)
SAZZAD HOSSAIN
SAZZAD HOSSAIN 2013 年 5 月 13 日
コメント済み: Jeff Bush 2016 年 4 月 21 日
Hello all
My program has a loop at the beginning which takes quite a while to finish. Most of the contents in the script comes after the loop. I know that my loop is giving me the correct result. But while working when i have to check the programme, i need to run the program (and the loop) every time, Which takes up unnecessary time. Given that I dont want to separate the program, is it possible to start the program each time from the lines after the loop?
Thanks in advance.
Sazzad

採用された回答

Lisa Wu
Lisa Wu 2013 年 5 月 13 日
Comment the loop,and redefine the varibles from the loop as constant,such as
% { while true % code
a = ...
b = ...
c = ...
......
end %}
% define varible as constant
a = 3;
b = 4;
.....
Hope can help you.

その他の回答 (2 件)

Ken Atwell
Ken Atwell 2013 年 5 月 15 日
I often run into similar situations. You can divide your script into multiple sections, and then run each section individually with buttons of keyboard accelerators. To create a new section, start a comment line with "%% "
%%First section
longSetUpRoutine
%%Second section
restOfTheProgram
This was called "cell mode" until fairly recently. Now, it is just referred to as running code in sections. I suggest you look into it -- it is huge time-saver for me.
Watch the two-minute video here for a primer. The video was recorded a couple of years ago under the older UI. If you are using a newer release of MATLAB (with a Toolstrip), you can find the controls under the "Editor" tab ("Run and Advance" etc.)
  1 件のコメント
Jeff Bush
Jeff Bush 2016 年 4 月 21 日
Excellent tip. Thank you!

サインインしてコメントする。


Yao Li
Yao Li 2013 年 5 月 13 日
Keep the results of the the loop in workspace. Select the subsequent codes which you wanna test, and press F9 (F7 in Mac OS). or create a new script stores only the specific lines of codes. Pls. make sure the previous results of the loop are still in workspace
  1 件のコメント
Yao Li
Yao Li 2013 年 5 月 13 日
yes, Lisa's suggestion is better. just comment the loop

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by