x=xopsw;
%devpsi=0;
%x(8)=x(8)+devpsi;%13zdot0.005865855311580
%x(12:end)=kron(eye(2),rotz(devpsi))*x(12:end);
InitSetUp;
[x0p,alr] = Striderest(xSt0,x);
computevcceq(x)
%%
x=xopsw;
%x(17)=xopsw(17)+0.02;
PlotSimHybr_FixH_BS_enh_NoMirr_enh(x,alr,1,20,1)
%PlotSimHybr_FixH_BS_enh_NoMirr(x,alr,1,100,1)
%%
for i=1:10
x=xopsw;
InitSetUp;
[x0p,alr] = Striderest(xSt0,x);
xSt0 = xSt0(5:12);
xf=Stride([phasphi(1);xSt0], NaN,x,alr);
x(16:end)=xf(2:end)
x(1)=xf(1)

end
%%
xopsw=[   0.046334284562866
  -5.355010042230490
   0.113524936450297
  -2.035906118674400
   4.954170143877920
   1.550635410871368
   5.165420748579254
   2.435748668787137
   2.674809901488776
   0.149457073807350
   0.846646376468854
   0.743743990645261
   0.054642291958716
   0.355987019879191
  -0.237653168642405
   0.125572488975305
   0.566559485228246
   1.113299684743702
   1.995390842602884
  -0.779869923535340
   0.535150016261177
   0.549135727176047
   0.248226304619958];
computevcceqmm(xopsw)
%%
xopsw=[  -0.026815018878195
  -4.450502888418503
   0.030677784061424
  -1.957522283777208
   4.207234041544054
   1.984603548832629
   4.869941269910178
   1.581285195743409
   3.897905837484961
   0.203183518615680
   0.516670028030145
   0.672551393389460
   0.082272277987265
   0.359087786014836
  -0.157670047866271
   0.123216866219804
   0.631714628208999
   1.005533780221584
   2.063284736698659
  -0.750659014469192
   0.430030022161396
   0.413826057946561
   0.200759285287397];
computevcceqmm(xopsw)
%%
xopsw=1.0e+02*[-0.000112341972486
  -0.037288481838217
   0.000663785539461
  -0.0211675323476306
   0.031634132619118
   0.01000937260203923%CSUSP
   0.0404345071941398%C
   0.01005224765430517%C
   0.051517990924977
   0.002822471500829
   0.006590814451952
   0.007756698478929
   0.002875203028683
   0.003587281817112
  -0.001538434005171
   0.001653854002405
   0.007253572599260
   0.010537064974476
   0.023396705375641
  -0.008150829641210
   0.004590581826340
   0.005297765985493
   0.002895538251976];
computevcceq(xopsw)
% tau0=10*x(4);
% kdtau=x(5);
% kpLe=1000*x(6);
% kpAz=10*x(7);
% kdLe=100*x(8);
%%
xopsw=[0.483402045959110
    -1.134494733854711
  -0.268527211814195
  -3.727902170264331
   6.782970042548285
   6.134937292875161
   6.569144892074585
   2.964828516208100
   8.219661473273501
   0.202109131115497
   0.299803329094701
   0.445535418216211
   0.422019223863767
   0.708149011360256
  -0.291796363655602
   0.231333571978532
   0.463039967200092
   1.762389722228661
   2.837783975548761
  -0.633938118750967
   0.296011588214347
   0.396863765140706
   0.374361969361109];
computevcceq(xopsw)
%%
xopsw=[   0.483402045959110
  -1.134494733854711
  -0.268527211814195
  -3.727902170264331
   6.782970042548285
   6.134937292875161
   6.569144892074585
   2.964828516208100
   8.219661473273501
   0.202109131115497
   0.299803329094701
   0.445535418216211
   0.422019223863767
   0.708149011360256
  -0.291796363655602
   0.231334449073986
   0.463042564648469
   1.762391194271780
   2.837780811617706
  -0.633949259107928
   0.296014038527707
   0.396863608505466
   0.374359574823201];
computevcceq(xopsw)
%%
xopsw=[0.370152870565441
  -1.134594672276226
  -0.245274819399123
  -3.848906690612655
   6.776041036540288
   6.198440772772403
   7.040609557456170
   2.702002077687264
   8.332087744331288
   0.253377046576483
   0.258461073013311
   0.433123210790387
   0.365967683817842
   0.699099424408978
  -0.255287260437172
   0.213046552281215
   0.525251565771473
   1.766712167403006
   2.939870274802229
  -0.599941524174483
   0.299862093873401
   0.420545142801454
   0.365199832108714];
computevcceq(xopsw)
%%
xopsw=[0.392450011875433
  -0.987179498122201
  -0.195884413235364
  -3.779615900507469
   6.101639110498043
   6.279673795035896
   7.084598591378736
   2.544062422829534
   8.131678910856996
   0.269384339056468
   0.291921963555935
   0.388037867386894
   0.359791109365532
   0.701101277305731
  -0.320014815467038
   0.253975174856070
   0.588005163149669
   1.982968298870573
   3.038945985319257
  -0.675297457756138
   0.444912686118144
   0.505202892871430
   0.337991314542233];
computevcceq(xopsw)
%%
xopsw=[0.298018213832475
  -1.447103672757478
  -0.130039830214402
  -4.160362665067960
   5.622324329630309
   6.087699538989451
   6.861596504106124
   2.501506653257143
   7.695124848937406
   0.331083534827247
   0.377275665513961
   0.729999936807322
   0.281549120662263
   0.595855098796194
  -0.281065548365161
   0.190398398611455
   0.589940542549217
   1.805223657246793
   3.238721219599646
  -0.909424655528873
   0.456150211552132
   0.686149763194224
   0.673462597054006];
computevcceq(xopsw)
%%

xopsw= [   0.174547472865521
  -2.989793406358777
   0.026837652588568
 -21.528213393064714
   3.514985407896324
  10.077073427530705
  40.532435962135409
   9.905351026048002
   5.600030561417103
   0.149571359363582
   0.668710097692177
   0.712013054788482
   0.251196211298017
   0.460794340023554
  -0.275514285450344
   0.164045834692033
   0.590760461674338
   1.267428077143814
   2.390099225927656
  -0.761383583297375
   0.588464103617993
   0.572493751016180
   0.301142771652694];
computevcceq(xopsw)
%% BEST with phase
xopsw=[0.150911925922091
  -1.532192582855513
   0.399555731623881
   4.146528688496236
   0.874177633421229
   1.807534100845350
   2.567782870387086
   0.005865855311580
   0.001751011348129
   0.000063837263941
  -0.156209939835345
   2.660572900097467
  -0.004886438878930
  -0.014141132125161
   0.535116506971628
  -0.000024596434117];
computevcceq(xopsw)
%% 
xopsw=[ 0.115470599157211
  -0.451461145972889
   0.676389883594941
   7.980050909866246
   0.855151050303329
   4.469431239845975
  10.276523029728267
   0.002843983247950
   0.193484153465418
  -0.000500040322348
  -0.249204806708557
   4.419768760523954
  -0.310137429691157
  -0.006306067261798
   0.918096967242714
  -0.000037414272278];
computevcceq(xopsw)
%%
xopsw2=[   0.102639705840634
  -1.519576239913157
   0.702210312086365
   6.821192226596296
   1.762750093596168
   1.696359908433516
   1.431226482094358
   0
   0.033752148010295
   0.014038920387988
   0.079242010232699
   1.738067289354849
  -0.067863198327278
  -0.009783522521821
   0.608885982950590
  -0.000647910271884];
%% 0.71 max eig
   0.180904952885326
  -2.743398447621160
   0.425743289190714
  25.939332669839430
   5.843221235558817
   1.018841668448083
   0.778962775152502
   0.111996996062463
   0.047885618186149
  -0.147110596913596
   2.395534318426255
  -0.142300076900749
  -0.015266347074846
   0.870542635363838
  -0.010218083471667
  %% 0.90 neg kd?
  
xopsw2=[0.101580838963885
  -2.243859155187994
   0.334158320453136
  -22.989882929632941
  4.738190371014960
   6.433385816052399
   1.670653024087921
   0.006406610061452
   0.021585496226857
   0.091105328213811
   2.878364684820466
  -0.062094598426906
  -0.004496744406721
   0.114378983107454
  -0.000240136133855]