MATLAB: Plotregression fitlm rsquare difference

fitlmOptimization ToolboxplotregressionrsquareStatistics and Machine Learning Toolbox

Hello
Could you help explain why there is a difference between r-squared calculated using plotregression() and fitlm()?
R-squared: 0.968 from fitlm() R = 0.98364 from plotregression()
The code to produce the two r-squared values is below.
%% set up variable from neural network output = net(input); outputTest = output(tr.testInd); targetTest = target(tr.testInd);
%% first method to produce r-squared plotregression(targetTest,outputTest,'Testing')
%% second method to produce r-squared mdl = fitlm(targetTest,outputTest); r2 = mdl.Rsquared.Ordinary;
Regards
William Bell

Best Answer

>> 0.98364^2
ans =
0.9675
Thank you for formally accepting my answer
Greg