MATLAB Answers

0

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

Asked by Arturs Vancans on 8 Oct 2019
Latest activity Answered by Walter Roberson
on 12 Oct 2019
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

  2 Comments

What command do you want to check?
I dont want to check anny command check is file name, that brings some output depending on z value

Sign in to comment.

2 Answers

Answer by Image Analyst
on 8 Oct 2019
 Accepted Answer

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

You can turn it off and on at anytime with the diary command.
I need to determin moment when to turn it off depending on command window output, how to include it in code?
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.


Answer by Walter Roberson
on 12 Oct 2019

Use evalc()

  0 Comments

Sign in to comment.