Membrane computing has a characteristic of great parallelism, so it has been applied in broad fields such as Biological modeling, NPC problems and combinatorial problems by reducing the computational time complexity greatly. In this paper we approach the problem of hierarchical clustering with a new method of membrane computing. An improved P system with external output is designed for finite set individuals with nonnegative integer variables. In the process of hierarchical clustering, the clustering is obtained depending on the dissimilarity between individuals or groups, so the less dissimilar two individuals are, the more similar they are. For an arbitrary matrix
representing the values of N individuals, one possible hierarchy with clusters can be obtained by this improved P system in a non-deterministic way. The time complexity is polynomial in the number of individuals, the number of variables and the certain maximum value
without increasing the complexity of the classical clustering algorithms. At the end of this paper, we cluster an example of dataset to obtain the final results. Through example test, we verify the feasibility and effectiveness of this improved P system to solve hierarchical clustering problems. A greater range of hierarchical clustering problems will be solved with this improved P system.