The trajectory planning for UAVs in the dynamic environments is a challenging task. Many restrictions should be taken into consideration, including dynamic terrain collision, no-fly zone criteria, power and fuel criteria and so on. However, some methods treat dynamic restrictions as static in order to reduce cost and obtain efficient and acceptable paths. To achieve optimal, efficient and acceptable paths, we first use a high-dimension matrix, Extended Hierarchical Graph (EHG), to model the unexplored dynamic grid environment and to convert weather conditions to passable coefficient. The original shortest path planning task is then translated to plan the safest path. Therefore, we propose a new forward-exploration and backward-navigation algorithm, Matrix Alignment Dijkstra (MAD), to pilot UAVs. We use matrix alignment operation to simulate the parallel exploration process of all cells from time t to t+1. This exploration process can be accelerated on a GPU. Finally, we recall the optimal path according to the navigator matrix. In addition, we can achieve UAV path planning from one source cell to multiple target cells within one single run. We validate our method on a real dynamic weather dataset and get competitive results in both efficiency and accuracy. We analyse the performance of MAD on a grid-based benchmark dataset and artificial maze data. Simulated results show MAD is especially helpful when the grid-based environment is large-scale and dynamic.