Look at the .serial file using the “more” command. Notice that the syntax is different; instead of using angled brackets to mark off the submitted function, quotes are used. Additionally, despite the fact that the input looks like an integer, if you look at the MATLAB function you’ll notice that the first line converts the input into an integer. All inputs from .serial files enter MATLAB as strings, so if you want to treat it as a number that has to be your first task in MATLAB.
If you call another function from within a MATLAB function or script – for example, if you wanted to call magic_function.m from within magic_script.m – you don’t have to first turn inputs into strings. So you would just use the line “magic_function(8);”, as you would running MATLAB on your laptop or a lab computer, for example.
As before, you need to change the save path in the MATLAB function before submission.
Submit with “bsub < funct_example.serial”.
To run a function or script immediately after this one – maybe you want to create magic squares for all numbers between 1 and 10 – copy the last line of the .serial file and paste it at the bottom of the file. Change whatever you want about it and then submit normally. This will run the jobs in series, beginning one after it finishes with the one before it.