%get the residual d_res=d_data-d_model; %plot the data, fitted values, and residual in the same plot figure(1); clf; subplot(3, 1, 1); plot(d_data); axis tight; ylabel('Data', 'FontSize', 18); title(['Two Parameters Estimation C=' num2str(C) ', K=' num2str(K)]); subplot(3, 1, 2); plot(d_model, 'r'); axis tight; ylabel('Model', 'FontSize', 18); subplot(3, 1, 3); plot(d_res, 'g'); axis tight; ylabel('Residual', 'FontSize', 18); %plot them in the same plot figure(2); clf; plot(d_data); hold on; plot(d_model, 'r--'); plot(d_res, 'g:'); hold off; legend('experimental data','model displacement', 'Residual'); xlabel('Time','FontSize', 18); ylabel('Displacement'); axis tight; %just plot the residual vs time %this is to check the dependence structure figure(3); clf; plot(d_res, 'g.'); axis tight; ylabel('Residual', 'FontSize', 18); xlabel('Time', 'FontSize', 18); %checking the residuals have the same variance or not %plot the residual vs. the fitted values figure(4); clf; plot(d_model, d_res, 'o'); axis tight; xlabel('Fitted Value', 'FontSize', 18); ylabel('Residual', 'FontSize', 18); %check whether the residuals are truly from Normal distribution %1. quantile-quantile plot figure(5); clf; qqplot(d_res); %2. normality-probablity plot figure(6); clf; normplot(d_res);