Download MuPAD from SciFace

MuPAD Pro Computing Essentials - Examples 

Example 5.7 User defined library of MuPAD procedures

In this example I show the simplest method how to build libraries of MuPAD procedures. This method can be quite useful while preparing teaching materials.   

Let us start by developing a notebook with a few procedures. In order to make it shorter, I will only use two procedures. However, you can develop as many of them as you wish. Here is my notebook:

  • average:=proc()
    local n, i, result;
    begin
       n:=args(0);
       result := 0;
       for i from 1 to n do
          result := result + args(i)
       end;
       result := result/n;
     return(result)
    end: 
      
  • squares := proc()
    local n, i, result;
    begin
       n:=args(0);
       result := 0;
       for i from 1 to n do
          result := result + args(i)^2
       end;
       return(result)
    end:   

Now is time to point out a place where you will save your library. Before executing next  two commands create in MuPAD root directory a new  folder "userlib".  Now you can execute the following two commands. 

  • WRITEPATH := "userlib": 
    write("myfunctions.mb", average, squares)

Next time, in order to load the library myfunctions.mb you shall execute these two commands.

  • READPATH := "userlib":
    read("myfunctions.mb"):

Now you can use any procedure that was defined in your library.    

You can place your user libraries in any place of your computer or a school network. In order to do this, in commands WRITEPATH and READPATH you shall specify absolute path to this place, for example:

  • READPATH := "h:\\userlib":
  • WRITEPATH := "h:\\userlib":

Note -- on Windows you need to use  "\\"  instead of "\". This is all. 

 

TOP