Hi Shahid,
I understand that you are trying to calculate p-values for a t-test and an F-test between two independent data sets. A t-test and F-test can be performed in MATLAB using the “ttest” (or “ttest2”) and “vartest2” functions respectively.

In MATLAB “ttest2” is used for unpaired samples while “ttest” is used for paired samples
Since the above data seems to be paired (calculated vs. observed for the same cases) the “ttest” function could be used:
[h, p_ttest] = ttest(A(1:length(B)), B);
fprintf('Paired t-test p-value: %f\n', p_ttest);
- h is 1 if the test rejects the null hypothesis at the 5% significance level.
- p_ttest is the p-value.
If your samples are not paired, use:
[h, p_ttest2] = ttest2(A(1:length(B)), B);
fprintf('Unpaired t-test p-value: %f\n', p_ttest2);
2. F-test (comparing variances): Test if the variances of two groups are significantly different.
[h, p_ftest] = vartest2(A(1:length(B)), B);
fprintf('F-test p-value: %f\n', p_ftest);
- h is 0 if variances are statistically similar, 1 if they are significantly different
- p_ftest is the p-value.
For more information, please refer to the MATLAB documentation links given below: