Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to shutdown computer in matlab scripts?

Tags:

matlab

I want to shutdown my computer in matlab scripts when the program has ran to end. Is there any commands about this?

like image 274
mining Avatar asked Jul 14 '26 21:07

mining


1 Answers

This should work: system('shutdown -s');

You can also try the following function as posted in Matlab Central.

function shutdown(varargin)
if nargin
   if isnumeric(varargin{1})
       if varargin{1} == -1
           evalc('!shutdown -a');
           return
       end
       t = ceil(varargin{1});
    else
       t = 60;
    end
else
   t = 60;
end
eval(['!shutdown -s -f -t ' num2str(t)])

USAGE:

  • shutdown = turn off the computer in 60 seconds
  • shutdown(numsec) = turn off the computer in numsec seconds
  • shutdown(-1) = abort the shutdown; don't turn off the computer
  • numsec = optional number of seconds to pause after system shutdown window is displayed (defualt is 60 seconds). If numsec is -1, then the command aborts a shutdown countdown currently in progress.
like image 176
sagunms Avatar answered Jul 17 '26 19:07

sagunms