close all;
kp=input('Enter the value of Kp used for this simulation: ');
kpstring=strcat('Kp=',num2str(kp,2));
plot(out.ScopeData(:,1),out.ScopeData(:,2),'k-',out.ScopeData(:,1),out.ScopeData(:,3),'r-');
grid on;
legend('Output','Setpoint');
xlabel('Time (seconds)');
ylabel('Position (radians');
text(6,0.35,kpstring);
figure;
error=out.ScopeData(:,2)-out.ScopeData(:,3);
plot(out.ScopeData(:,1),error);
xlabel('Time (seconds)');
ylabel('Position Error');
grid on;
error=abs(error);
[maxError,maxErrorIndex]=max(error);
maxTime=out.ScopeData(maxErrorIndex,1);
maxErrorStr=strcat('Maximum Error=',num2str(maxError,5));
maxTimeStr=strcat('Maximum Error occurs at: ',num2str(maxTime,5),' Seconds');
text(6,-0.4*maxError,maxErrorStr);
text(6,-0.5*maxError,maxTimeStr);