Hi Yang,
I will help you guide to resolve your problem. First, define the two matrices matrix1 and matrix2 with random values for demonstration purposes, initialize a slope_matrix of size 96x150 to store the slopes. Then, use nested loops, we iterate over each time point and each data point column in matrix 2. For each iteration, you need to fit a linear model using fitlm to find the slope (a) for the data points at that time point. Then, the slope value is extracted from the model and stored in the corresponding position in the slope_matrix. Finally, the slope_matrix containing all the slopes is displayed. I just ran this code in Matlab to obtain a slope matrix (96x150) that represents the slopes of the linear fits for each data point at every time point. Please see attached results.
If you have further questions, please let me know.