Loop data in both x and y direction, and do linear fit of each y at each x
댓글 수: 5
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.
채택된 답변
추가 답변 (1개)
카테고리
도움말 센터 및 File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!