Matlab 2018-course, Q&A, instructions

  • Passing parameters, local variables, Apollosys.m.
    Some students had problems with Apollosys. It may be confusing that the Apollotemplate.m-file contains the lines:
        mu=1/82.45;
        lam=1-mu;
    
    This doesn't mean that the Apollosys-function gets these values, on the contrary, the inside of Apollosys (like any function) is totally unaware of the variables in the outside workspace and vice versa. (Otherwise serious conflicts between these "worlds" would be possible.)
    So please include these as (local) variables in Apollosys.m.

    Another thing is passing parameters which you like to change, as discussed during the lectures. But here, we don't like to change the masses of moon and earth :-)

    Parameter passing is also well explained in this eBook, mentioned on the index-page, see Section 1.2.

    More instructions on the Apollo and also ex4 later and when more questions arise.

  • Triton userid
    Login: scip
    Password: M...Lab...2018   (send email if (...) forgotten)
    Valid till: 2018-03-16
    slogin -X -lscip triton.aalto.fi 
    $ cd $WRKDIR
    $ mkdir USER_OWN_DIR
    $ module load matlab
    $ matlab&
    
  • Q: How to give default values of input arguments?
    A: There is a variable nargin (Number of input argunebts) that can be tested in the function body.
       function y=mytest(x,y,z)
       if nargin<3 
         z=10 % Default value for z
       ...
    
    It is often useful to look at Matlab's functions (many have open source, the s.k. builtin functions don't). A good example here is linspace Just >> type linspace