path="../csv"
t1,s1=lib.step_response([0.75],[1,0.5,1])
t2,s2=lib.step_response([0.75],[1,-2,1])

np.savetxt("%s/fig1.csv" % path,np.matrix([t1,s1]).T,header="t,s", delimiter=",")
np.savetxt("%s/fig2.csv" % path,np.matrix([t2,s2]).T,header="t,s", delimiter=",")

#system1
t3,s3=lib.step_response([1,3,2],[1,10,33,46,30])
np.savetxt("%s/fig3.csv" % path,np.matrix([t3,s3]).T,header="t,s", delimiter=",")

#system2
t4,s4=lib.step_response([1,3],[1,6,10,-2,-15])
np.savetxt("%s/fig4.csv" % path,np.matrix([t4,s4]).T,header="t,s", delimiter=",")

#critere du revers
w,mag,phase=lib.bode([2],[1,3,3,1])
np.savetxt("%s/fig5_bode.csv" % path,np.matrix([w,mag,phase]).T,header="w,mag,phase", delimiter=",")

t5,s5=lib.step_response_BF([2],[1,3,3,1])
np.savetxt("%s/fig5_BF.csv" % path,np.matrix([t5,s5]).T,header="t,s", delimiter=",")

w,mag,phase=lib.bode([20],[1,3,3,1])
np.savetxt("%s/fig6_bode.csv" % path,np.matrix([w,mag,phase]).T,header="w,mag,phase", delimiter=",")

t6,s6=lib.step_response_BF([20],[1,3,3,1])
np.savetxt("%s/fig6_BF.csv" % path,np.matrix([t6,s6]).T,header="t,s", delimiter=",")

import sys
import numpy as np
from matplotlib import pyplot as plt

sys.path.append('../../control_engineering_lib')
import control_engineering as lib


path="../csv"

num=1;
den=[1,3,3,1]
t=np.linspace(0,30,101)

w,mag,phase=lib.bode(num,den)
np.savetxt("%s/bode_sys.csv" % path,np.matrix([w,mag,phase]).T,header="w,mag,phase", delimiter=",")

t,s=lib.step_response_BF(num,den,1,t)
np.savetxt("%s/step_sys.csv" % path,np.matrix([t,s]).T,header="t,s", delimiter=",")

#correcteur P
Cnum=2.9
Cden=1

w,mag,phase=lib.bode(Cnum,Cden)
np.savetxt("%s/cor1_bode.csv" % path,np.matrix([w,mag,phase]).T,header="w,mag,phase", delimiter=",")

w,mag,phase=lib.bode_cor(num,den,Cnum,Cden)
np.savetxt("%s/syscor1_bode.csv" % path,np.matrix([w,mag,phase]).T,header="w,mag,phase", delimiter=",")