How to grab message from command window and take action in code depending on it.

1 view (last 30 days)
How to check command window output and performe action depending on it.
for k = 1:500;
z=z+1;
check(z); %% check.p file checking z and gives output in command window
%% code that should breake the code if command window throws "z is correct"
end

Accepted Answer

Image Analyst
Image Analyst on 8 Oct 2019
I'm almost certain you do not want to do what you asked. It's bizarre. Why not just write a normal program with a GUI or an inputdlg() to ask the user for some input? Or if it was something printed/echoed to the command window by a line of code in your program, just send that line directly to whatever other code needs it.
  6 Comments
Arturs Vancans
Arturs Vancans on 10 Oct 2019
I need to determin moment when to turn it off depending on command window output, how to include it in code?
Image Analyst
Image Analyst on 12 Oct 2019
Open the diary file and search for the stopping condition with strfind() or endsWith(). If you find it, turn the diary off. Then since no diary will be continued I guess you'll have to determine somehow in your code when to start logging output to the diary again.

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 12 Oct 2019
Use evalc()

Categories

Find more on Programming in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!