## 1 Introduction
For the BESO method, [PERSON] and [PERSON] [22] gave a soft-kill BESO Matlab code that can be used to solve simple 2D stiffness optimization problems, which is developed based on the 99-line Matlab code. For the level set method, [PERSON] and [PERSON] [23] presented a 129-line Matlab code of the level set method for topology optimization, which can be used for multiple load cases. [PERSON] et al. [24] presented an 88-line Matlab code for parameterized level set method-based topology optimization using radial basis functions. For the MMC method, [PERSON] et al. [25] proposed an ersatz material model and presented a 188-line Matlab code for a topology optimization approach-based MMC framework. [PERSON] et al. [26] further extended it to 3D and obtained an easy-to-extend 256-line Matlab code of the MMC method for the topology optimization of 3D structures. For the homogenization method, [PERSON] and [PERSON] [27] presented a Matlab code for the topology optimization of materials with extreme properties based on the 88-line Matlab code. [PERSON] et al. [28] presented a 149-line Matlab code to solve the topology optimization problem with the numerical homogenization method for 3D cellular materials. There are still more educational papers that we cannot review in this paper, and all of these educational papers have significantly contributed to the development of topology optimization [29]. However, there is little work in educational papers on topology optimization of multi-materials, especially for 3D structures. [PERSON] and [PERSON] [30] combined the classical binary phase topology optimization algorithm and the block coordinate descent algorithm and introduced a 115-line Matlab code for solving the multi-material topology optimization problem. [PERSON] [31] adopted both the ZPR update scheme and the DMO material interpolation scheme for the topology optimization of multi-materials with compliance minimization under volume constraints and presented an educational code named PolyMat by extending the educational code PolyTop. [PERSON] [32] proposed a level set topology optimization algorithm for multi-materials. The evolution of the design is guided by topological derivatives, which can effectively circumvent the problem of the level set topology optimization method that requires the selection of a perforated initial design. In addition, a Matlab code implementation of an academic multi-material topology optimization problem is also given. However, these focused on 2D problems only, and they are still complex for a new researcher to follow the work. Hence, we extend the 88-line code for the topology optimization of multi-materials by using the mapping-based interpolation function proposed by [PERSON] [16] in this paper. Implementation with 2D Matlab for the topology optimization of multi-materials with minimum compliance under volume constraints is shown in detail, and compact and complete 2D and 3D Matlab codes are given in the Appendices A and B which will contribute to educating about the topology optimization of multi-materials. The remainder of this paper is organized as follows. In Section 2, the formulation for topology optimization of multi-materials is described generally, including the filtering, the projection, the mapping-based interpolation function, and the optimization model procedures. A detailed implementation of 2D multi-material topology optimization with Matlab code is presented in Section 3. Then, a number of examples are provided by running the code, as shown in Section 4. An extension of the proposed method to the 3D multi-material topology optimization problem and its numerical examples are presented in Section 5. Finally, conclusions are drawn. Complete Matlab codes are given in the Appendices A and B.