Matlab m-file for generating Figure 3.5  main_piex2.m