tHi,
I understand that you have two groups, namely "normal" and "competition," and you would like to assess the linearity of the data and calculate the best-fitting linear function for each group. Additionally, you are interested in applying a "t-test" to compare the slopes within each group.
To address the differences between the two groups, analyzing the linearity and fitting linear functions separately for each group allows you to compare and understand the specific relationships between variables within each group. The figure you provided indicates that the slope of the "normal" group is less than that of the "competition" group.
To apply linear fitting to your data, you can refer to the MATLAB documentation for the "fitlm" function. Additionally, you can find more information and insights by following the provided discussion link.
Calculating the slope from the linear fit model can be achieved using the "fitlm" function. The provided link offers a discussion on obtaining the slope from "fitlm" results:
To perform a "t-test" on the slopes of both models, you can utilize the "ttest2" function in MATLAB. This function enables a two-sample "t-test" comparison of the slopes between the two groups. The resulting "p-value" indicates the significance of the difference between the slopes. The MATLAB documentation provides detailed information on how to use the "ttest2" function.