0

I've got a Matlab script which needs to be run every time the system reboots. I've got the Matlab setup on a system server. The system reboots every week (On Sunday, but not specific to any time period).

Can I run the m-file every time the system reboots?

user3459379
  • 1
  • 1
  • 2
  • Call your MATLAB script from `startup.m`. – am304 Jul 14 '17 at 10:42
  • Sorry, I'm new to it. But should I write a call statement in the startup.m? Also, where can I find startup.m? – user3459379 Jul 17 '17 at 14:11
  • See http://uk.mathworks.com/help/matlab/ref/startup.html, but you should really learn the MATLAB basics first, see the tutorials at https://uk.mathworks.com/support/learn-with-matlab-tutorials.html. – am304 Jul 17 '17 at 16:33

1 Answers1

0

You can run any matlab script from the terminal using the command

matlab -nodisplay myfile.m

So if you include that line in a batch script, which your system runs at startup, it should be run every time your system reboots.

Nicky Mattsson
  • 3,052
  • 12
  • 28
  • I'm new to MATLAB, sorry but it would sound a little amateur. How do I change the directory to wherever the m-file is located? Should I also place the batch file in the same folder? – user3459379 Jul 17 '17 at 13:41
  • In batch you change the directory by using the command `cd *directory*`. If I were to do what you are doing I would probably change the directory to the one where the matlab scribt is located, run it using the above command, then change back again. – Nicky Mattsson Jul 18 '17 at 14:51