load ProjectPI;

time = outputdata(1,:);
e_qp = outputdata(2,:);
i_d = outputdata(3,:);
i_kd = outputdata(4,:);
psi_d = outputdata(5,:);

number = length(time)

figure(1)
subplot(2,1,1)
plot(time,e_qp,'r-');
axis([-5 40 0 1.1]);
grid on;
xlabel('Time (seconds)');
ylabel('Voltage (Volts)');
title('e_qp vs. Time','FontSize',12);

subplot(2,1,2)
plot(time,i_d,'r-');
axis([-5 40 -0.5 0.1]);
grid on;
xlabel('Time (seconds)');
ylabel('Current (Ampere)');
title('i_d vs. Time','FontSize',12)
pause;

figure(2)
subplot(2,1,1)
plot(time,i_kd,'r-');
axis([-1 5 0 0.2]);
grid on;
xlabel('Time (seconds)');
ylabel('Current (Ampers)');
title('i_kd vs. Time','FontSize',12);

subplot(2,1,2)
plot(time,psi_d,'r-');
axis([-5 40 0.0 1.1]);
grid on;
xlabel('Time (seconds)');
ylabel('Flux Linkages (Webers)');
title('psi_d vs. Time','FontSize',12)

OPF = fopen('file1.dat','w');

for n=1:number
 fprintf(OPF,'%5.3f  %5.3f \n',time(n), e_qp(n));
end;

fclose(OPF);