Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sim command without command window output

I'm using the sim command in a Matlab script to run a Simulink model. This simulink model display some stuff in the command window. What is the option for the sim command to remove any display that would go in the command window? So is there something similar to this that exist :

sim('model', 'CommandWindowDisplayVisible', 'off');

Update:

From what I found, there appears to be no such thing possible with the sim command. Here what I did as an alternative :

s = sprintf('sim(''%s'')', ModelName);
try
  evalc(s);
catch err
  msgString = getReport(err, 'extended');
  disp(msgString)
end
like image 637
m_power Avatar asked Feb 19 '26 17:02

m_power


1 Answers

You could try using evalc to capture the output to a variable. This way it is not displayed in the command window.

for example

sim('model')

produces output, whereas:

myCommandWindowOutput = evalc('sim(''model'')');

doesn't.

In fact, you don't even need to assign the output, you could just write:

evalc('sim(''model'')');

http://www.mathworks.co.uk/help/matlab/ref/evalc.html

like image 173
Huguenot Avatar answered Feb 24 '26 09:02

Huguenot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!