%%% C:/work/PLPaper2/simul/NewSpdCmp.txt

****************************************************************************
******
******  27 June 2005 -- Compare the speed of learning of the new model
******  PLM_Hebb2 with and without feedback, everything else being equal.
******
******  See C:/work/PLPaper2/simul/SpeedCompar.txt for an analogous speed
*****   comparison with the original PLM_Hebb1 model (used in PLPaper1).
******
******  Main loop:   % see functions NEWSPDCMP32.M and NEWSPDCMP36.M.
******    Generate N_RUNS stimulus sequences
******    Run PLM_HEBB2 with feedback-optimized parameters
******    Run PLM_HEBB2 with no-feedback-optimized parameters
******    Fit exponential regressions to both, store the resulting TAUs
******  Repeat for N_EPOCHS
******
****************************************************************************

>> cd(PLM_path);   % 'C:\work\PLModel1' or 'C:\Users\apetrov\PLModel1'
>> cd('..\PLPaper2\simul');

>> clear all;global PLM_CACHE;load('..\..\PLModel1\PLM_CACHE.mat');clear Idef;

>> k=1;Mpar(k)=PLM_params;Mpar(k).fdbk_fract=0;Mpar(k).criterion=2.14;Mpar(k)
Mpar(1) =                 % near-optimal params for running without feedback
      rep_size: [7 5 1]
       max_act: 0.5000
      rep_gain: 0.8000
      out_gain: 5
     rep_noise: 0.1000
     out_noise: 0.1600
      W_minmax: [-1 1]
        W_init: 0.1700
       W0_seed: [35x1 double]
    learn_rate: 0.0016
    runav_rate: 0.0200
     criterion: 2.1400
      fdbk_wgt: 1
    fdbk_fract: 0
      blk_size: 300

>> k=2;Mpar(k)=Mpar(1);Mpar(k).fdbk_fract=1;  % same params, with feedback
>> k=3;Mpar(k)=Mpar(2);Mpar(k).out_noise=.18;Mpar(k).criterion=2.207;Mpar(k).fdbk_wgt=0.156;Mpar(k)
>> k=4;Mpar(k)=Mpar(3);Mpar(k).out_noise=.21;Mpar(k).criterion=2.247;Mpar(k).fdbk_wgt=1;Mpar(k)

>> pack_fields(Mpar,[],'cols2cols')
%                1      2      3      4
%--------------------------------------------
    fdbk_fract: [0      1      1      1     ]
     out_noise: [0.1600 0.1600 0.1800 0.2100]   %<-- Sic
     criterion: [2.1400 2.1400 2.2070 2.2470]   %<-- Sic
      fdbk_wgt: [1      1      0.1560 1     ]
%--------------------------------------------
      rep_gain: 0.8000
      out_gain: 5
     rep_noise: 0.1000
        W_init: 0.1700
    learn_rate: 0.0016
    runav_rate: 0.0200
%--------------------------------------------

>> tic;sst32=NewSpdCmp32(Mpar);save('foo32.mat');toc; 
% Elapsed time ~10 minutes on IBM 8310!!

>> tic;sst36=NewSpdCmp36(Mpar);save('foo36.mat');toc
% Elapsed time ~10 minutes on IBM 8310!!

%% Discard all sumstats fields except the first four:
%% N_runs, zP_congr, zP_incon, dprime, accZP
>> discard=fields(sst32);discard=discard(6:end);sst32=rmfield(sst32,discard)
>> discard=fields(sst36);discard=discard(6:end);sst36=rmfield(sst36,discard)
>> save(fullfile(work_pathstr,'PLPaper2','simul','sumstats26Jun05.mat'),'Mpar','sst32','sst36');


%-- Plot the d-primes. k1='o-'=trial-by-trial fdbk, k1='.-'=no fdbk, same stimuli, same parameters
k1=2;k2=1;L=sst32;tL=[1:32]';R=sst36;tR=[1:36]';titleL='w/ and w/o fdbk; oN=.16, b=2.14, Wf=1.0';titleR=titleL;
subplot(3,2,1);plot(tL,L(k1).dprime,'bo-',tL,L(k2).dprime,'.r-');axis([0 37 0 3.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('d''');title(titleL);
subplot(3,2,2);plot(tR,R(k1).dprime,'bo-',tR,R(k2).dprime,'.r-');axis([0 37 0 3.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('d''');title(titleR);
subplot(3,2,3);plot(tL,L(k1).zP_congr,'bo-',tL,L(k2).zP_congr,'.r-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title(['o=' vect2str(L(k1).accZP(1:3),'%.3f') '  .='  vect2str(L(k2).accZP(1:3),'%.3f')]);
subplot(3,2,4);plot(tR,R(k1).zP_congr,'bo-',tR,R(k2).zP_congr,'.r-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title(['o=' vect2str(R(k1).accZP(1:3),'%.3f') '  .='  vect2str(R(k2).accZP(1:3),'%.3f')]);
subplot(3,2,5);plot(tL,L(k1).zP_incon,'bo-',tL,L(k2).zP_incon,'.r-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title(['o=' vect2str(L(k1).accZP(4:6),'%.3f') '  .='  vect2str(L(k2).accZP(4:6),'%.3f')]);
subplot(3,2,6);plot(tR,R(k1).zP_incon,'bo-',tR,R(k2).zP_incon,'.r-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title(['o=' vect2str(R(k1).accZP(4:6),'%.3f') '  .='  vect2str(R(k2).accZP(4:6),'%.3f')]);

%-- Plot the d-primes. k1='o-'=trial-by-trial fdbk, k1='.-'=no fdbk, same stimuli, same parameters
k1=3;k2=4;L=sst32;tL=[1:32]';R=sst36;tR=[1:36]';titleL='o/. = oN=.18/21, b=2.207/2.247, Wf=.156/1.0';titleR=titleL;
subplot(3,2,1);plot(tL,L(k1).dprime,'bo-',tL,L(k2).dprime,'.r-');axis([0 37 0 3.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('d''');title(titleL);
subplot(3,2,2);plot(tR,R(k1).dprime,'bo-',tR,R(k2).dprime,'.r-');axis([0 37 0 3.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('d''');title(titleR);
subplot(3,2,3);plot(tL,L(k1).zP_congr,'bo-',tL,L(k2).zP_congr,'.r-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title(['o=' vect2str(L(k1).accZP(1:3),'%.3f') '  .='  vect2str(L(k2).accZP(1:3),'%.3f')]);
subplot(3,2,4);plot(tR,R(k1).zP_congr,'bo-',tR,R(k2).zP_congr,'.r-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title(['o=' vect2str(R(k1).accZP(1:3),'%.3f') '  .='  vect2str(R(k2).accZP(1:3),'%.3f')]);
subplot(3,2,5);plot(tL,L(k1).zP_incon,'bo-',tL,L(k2).zP_incon,'.r-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title(['o=' vect2str(L(k1).accZP(4:6),'%.3f') '  .='  vect2str(L(k2).accZP(4:6),'%.3f')]);
subplot(3,2,6);plot(tR,R(k1).zP_incon,'bo-',tR,R(k2).zP_incon,'.r-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title(['o=' vect2str(R(k1).accZP(4:6),'%.3f') '  .='  vect2str(R(k2).accZP(4:6),'%.3f')]);


************************************************************
****
**** 27 June 2005 -- Compare fdbk and no-fdbk conditions head to head
****

>> k=5;Mpar(k)=Mpar(3);Mpar(k).fdbk_fract=0;Mpar(k)     % k=5=nofk, k=3=fdbk
      rep_gain: 0.8000
      out_gain: 5
     rep_noise: 0.1000
     out_noise: 0.1800
        W_init: 0.1700
       W0_seed: [35x1 double]
    learn_rate: 0.0016
    runav_rate: 0.0200
     criterion: 2.2070
      fdbk_wgt: 0.1560

>> tic;idx=5;s32=NewSpdCmp32(Mpar(idx));s36=NewSpdCmp36(Mpar(idx));toc
% elapsed_time = 6 min
>> discard=fields(s32);discard=discard(6:end);s32=rmfield(s32,discard)
>> sst32(idx)=s32;sst36(idx)=s36;

%-- Plot the d-primes. k1='o-'=trial-by-trial fdbk, k1='.-'=no fdbk, same stimuli, same parameters
k1=3;k2=5;L=sst32;tL=[1:32]';R=sst36;tR=[1:36]';titleL='w/ and w/o fdbk; oN=.18, b=2.21, Wf=.156';titleR=titleL;
subplot(3,2,1);plot(tL,L(k1).dprime,'bo-',tL,L(k2).dprime,'.r-');axis([0 37 0 3.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('d''');title(titleL);
subplot(3,2,2);plot(tR,R(k1).dprime,'bo-',tR,R(k2).dprime,'.r-');axis([0 37 0 3.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('d''');title(titleR);
subplot(3,2,3);plot(tL,L(k1).zP_congr,'bo-',tL,L(k2).zP_congr,'.r-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title(['o=' vect2str(L(k1).accZP(1:3),'%.3f') '  .='  vect2str(L(k2).accZP(1:3),'%.3f')]);
subplot(3,2,4);plot(tR,R(k1).zP_congr,'bo-',tR,R(k2).zP_congr,'.r-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title(['o=' vect2str(R(k1).accZP(1:3),'%.3f') '  .='  vect2str(R(k2).accZP(1:3),'%.3f')]);
subplot(3,2,5);plot(tL,L(k1).zP_incon,'bo-',tL,L(k2).zP_incon,'.r-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title(['o=' vect2str(L(k1).accZP(4:6),'%.3f') '  .='  vect2str(L(k2).accZP(4:6),'%.3f')]);
subplot(3,2,6);plot(tR,R(k1).zP_incon,'bo-',tR,R(k2).zP_incon,'.r-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title(['o=' vect2str(R(k1).accZP(4:6),'%.3f') '  .='  vect2str(R(k2).accZP(4:6),'%.3f')]);
% Figure saved as PLPaper2\simul\SpdCmp_fdbk32_oN18.pdf


%%%%% fdbk32_oN17 with and without fdbk
>> k=6;Mpar(k)=Mpar(3);Mpar(k).out_noise=.17;Mpar(k).fdbk_wgt=.092;Mpar(k)
>> k=7;Mpar(k)=Mpar(6);Mpar(k).fdbk_fract=0;Mpar(k)
      rep_gain: 0.8000
      out_gain: 5
     rep_noise: 0.1000
     out_noise: 0.1700
        W_init: 0.1700
    learn_rate: 0.0016
    runav_rate: 0.0200
     criterion: 2.2070
      fdbk_wgt: 0.0920
    fdbk_fract: 0         % 0 for k=7, 1 for k=6

>> tic;idx=[6 7];s32=NewSpdCmp32(Mpar(idx));s36=NewSpdCmp36(Mpar(idx));toc
% elapsed_time = 11 min
>> s32=rmfield(s32,discard);sst32(idx)=s32;sst36(idx)=s36;
>> save(fullfile(work_pathstr,'PLPaper2','simul','sumstats26Jun05.mat'),'Mpar','sst32','sst36');

%-- Plot the d-primes. k1='o-'=trial-by-trial fdbk, k1='.-'=no fdbk, same stimuli, same parameters
k1=6;k2=7;L=sst32;tL=[1:32]';R=sst36;tR=[1:36]';titleL='w/ and w/o fdbk; oN=.17, Wf=.092, b=2.21';titleR=titleL;
subplot(3,2,1);plot(tL,L(k1).dprime,'bo-',tL,L(k2).dprime,'.r-');axis([0 37 0 3.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('d''');title(titleL);
subplot(3,2,2);plot(tR,R(k1).dprime,'bo-',tR,R(k2).dprime,'.r-');axis([0 37 0 3.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('d''');title(titleR);
subplot(3,2,3);plot(tL,L(k1).zP_congr,'bo-',tL,L(k2).zP_congr,'.r-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title(['o=' vect2str(L(k1).accZP(1:3),'%.3f') '  .='  vect2str(L(k2).accZP(1:3),'%.3f')]);
subplot(3,2,4);plot(tR,R(k1).zP_congr,'bo-',tR,R(k2).zP_congr,'.r-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title(['o=' vect2str(R(k1).accZP(1:3),'%.3f') '  .='  vect2str(R(k2).accZP(1:3),'%.3f')]);
subplot(3,2,5);plot(tL,L(k1).zP_incon,'bo-',tL,L(k2).zP_incon,'.r-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title(['o=' vect2str(L(k1).accZP(4:6),'%.3f') '  .='  vect2str(L(k2).accZP(4:6),'%.3f')]);
subplot(3,2,6);plot(tR,R(k1).zP_incon,'bo-',tR,R(k2).zP_incon,'.r-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title(['o=' vect2str(R(k1).accZP(4:6),'%.3f') '  .='  vect2str(R(k2).accZP(4:6),'%.3f')]);
% Figure saved as PLPaper2\simul\SpdCmp_fdbk32_oN17.pdf


%%%%% fdbk32_oN16 with and without fdbk
>> k=8;Mpar(k)=Mpar(6);Mpar(k).out_noise=.16;Mpar(k).fdbk_wgt=.048;Mpar(k)
>> k=9;Mpar(k)=Mpar(k-1);Mpar(k).fdbk_fract=0;Mpar(k)
>> tic;idx=[8 9];s32=NewSpdCmp32(Mpar(idx));s36=NewSpdCmp36(Mpar(idx));s32=rmfield(s32,discard);sst32(idx)=s32;sst36(idx)=s36;toc
>> save(fullfile(work_pathstr,'PLPaper2','simul','sumstats26Jun05.mat'),'Mpar','sst32','sst36');

%-- Plot the d-primes. k1='o-'=trial-by-trial fdbk, k1='.-'=no fdbk, same stimuli, same parameters
k1=8;k2=9;L=sst32;tL=[1:32]';R=sst36;tR=[1:36]';titleL='w/ and w/o fdbk; oN=.16, Wf=.048, b=2.21';titleR=titleL;
subplot(3,2,1);plot(tL,L(k1).dprime,'bo-',tL,L(k2).dprime,'.r-');axis([0 37 0 3.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('d''');title(titleL);
subplot(3,2,2);plot(tR,R(k1).dprime,'bo-',tR,R(k2).dprime,'.r-');axis([0 37 0 3.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('d''');title(titleR);
subplot(3,2,3);plot(tL,L(k1).zP_congr,'bo-',tL,L(k2).zP_congr,'.r-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title(['o=' vect2str(L(k1).accZP(1:3),'%.3f') '  .='  vect2str(L(k2).accZP(1:3),'%.3f')]);
subplot(3,2,4);plot(tR,R(k1).zP_congr,'bo-',tR,R(k2).zP_congr,'.r-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title(['o=' vect2str(R(k1).accZP(1:3),'%.3f') '  .='  vect2str(R(k2).accZP(1:3),'%.3f')]);
subplot(3,2,5);plot(tL,L(k1).zP_incon,'bo-',tL,L(k2).zP_incon,'.r-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title(['o=' vect2str(L(k1).accZP(4:6),'%.3f') '  .='  vect2str(L(k2).accZP(4:6),'%.3f')]);
subplot(3,2,6);plot(tR,R(k1).zP_incon,'bo-',tR,R(k2).zP_incon,'.r-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title(['o=' vect2str(R(k1).accZP(4:6),'%.3f') '  .='  vect2str(R(k2).accZP(4:6),'%.3f')]);
% Figure saved as PLPaper2\simul\SpdCmp_fdbk32_oN16.pdf



***************************************************************************
****
****  30 June 2005  --  NEW DEFAULT PARAMETERS for PLM_Hebb2, ver 2.1
****  See C:\work\PLModel1\newsimul\Hebb2m_fits.txt for details.
****
****  For the PLExp1 data set (32 blocks, with feedbk). Based on e32_oN17a.
****    out_gain = 5
****    out_noise = .170    % was .195 in PLPaper1
****    fdbk_wgt = 1.80
****    fdbk_mode = 1 = 'intervene only on error'
****    fdbk_fract = 1 = 'scan all trials'
****    learn_rate = .0016  % was .0015 in PLPaper1 and in ver 2.0
****    criterion = 2.20    % same as in PLPaper1
****    W_init = .17        % same as in PLPaper1 and in ver 2.0
****
****  For the PLExp2 data set (36 blocks, without fdbk). Based on n36_par2.
****  Same parameters as above, except
****    fdbk_fract = 0    (or equivalently, fdbk_mode = 0)
****    out_noise = .156    % was .158 in ver 2.0
****    criterion = 0.95    % was 0.87 in ver 2.0
****
***************************************************************************


***************************************************************************
****
**** 30 June 2005 -- Compare the 4 fdbk modes under the new default Mparams
****

>> clear all; cd(fullfile(work_pathstr,'PLPaper2','simul'));
>> global PLM_CACHE;load(fullfile(PLM_pathstr,'PLM_CACHE.mat'));clear Idef;
>> load(fullfile(work_pathstr,'PLPaper2','simul','all_zP_data.mat'));clear mdprfk32 mdprnf36 mZfk32 mZnf36;
>> global HUMAN_ZCONGR ; HUMAN_ZCONGR = eZfk32'; whos

  Name               Size                   Bytes  Class
-------------------------------------------------------------------------
  HUMAN_ZCONGR       6x32                    1536  double array (global)
  PLM_CACHE         12x1                 16802736  struct array (global)
  eZfk32            32x6                     1536  double array
  eZnf36            36x6                     1728  double array
  edprfk32          32x3                      768  double array
  edprnf36          36x3                      864  double array
-------------------------------------------------------------------------

>> k=1;Mpar(k)=PLM_params       % new defaults, ver 3.3, June 30, 2005
Mpar(1) = 
      rep_size: [7 5 1]
       max_act: 0.5000
      rep_gain: 0.8000
      out_gain: 5
     rep_noise: 0.1000
     out_noise: 0.1700
      W_minmax: [-1 1]
        W_init: 0.1700
       W0_seed: [35x1 double]
    learn_rate: 0.0016
    runav_rate: 0.0200
     criterion: 2.2000
      fdbk_wgt: 1.8000
    fdbk_fract: 1
     fdbk_mode: 1         % default = 'intervene only on error'
      blk_size: 300

>> k=2;Mpar(k)=Mpar(1);Mpar(k).fdbk_mode=2;     % intervene only on correct trials
>> k=3;Mpar(k)=Mpar(1);Mpar(k).fdbk_mode=3;     % intervene on all trials
>> k=4;Mpar(k)=Mpar(1);Mpar(k).fdbk_mode=0;Mpar(k).fdbk_fract=0;   % no feedback

>> k=8;Mpar(k)=Mpar(1);Mpar(k).fdbk_fract=0;Mpar(k).fdbk_mode=0;Mpar(k).out_noise=.156;Mpar(k).criterion=.95;Mpar(k)    % PLExp2 defaults
Mpar(8) = 
      rep_size: [7 5 1]
       max_act: 0.5000
      rep_gain: 0.8000
      out_gain: 5
     rep_noise: 0.1000
     out_noise: 0.1560
      W_minmax: [-1 1]
        W_init: 0.1700
       W0_seed: [35x1 double]
    learn_rate: 0.0016
    runav_rate: 0.0200
     criterion: 0.9500
      fdbk_wgt: 1.8000
    fdbk_fract: 0
     fdbk_mode: 0
      blk_size: 300

>> k=5;Mpar(k)=Mpar(8);Mpar(k).fdbk_mode=1;Mpar(k).fdbk_fract=1;
>> k=6;Mpar(k)=Mpar(8);Mpar(k).fdbk_mode=2;Mpar(k).fdbk_fract=1;
>> k=7;Mpar(k)=Mpar(8);Mpar(k).fdbk_mode=3;Mpar(k).fdbk_fract=1;

>> pack_fields(Mpar,[],'cols2cols')
%     Mpar(k)=      1    2    3    4     5    6    7    8
%----------------------------------------------------------
    fdbk_fract: [   1    1    1    0     1    1    1    0]
     fdbk_mode: [   1    2    3    0     1    2    3    0]
     out_noise: [.170 .170 .170 .170  .156 .156 .156 .156]
     criterion: [2.20 2.20 2.20 2.20  0.95 0.95 0.95 0.95]
%----------------------------------------------------------
      rep_gain: 0.8000
      out_gain: 5
     rep_noise: 0.1000
        W_init: 0.1700
    learn_rate: 0.0016
    runav_rate: 0.0200
      fdbk_wgt: 1.8000
%----------------------------------------------------------

>> save(fullfile(work_pathstr,'PLPaper2','simul','go_NewSpdCmp.mat'));

%%%%%%  Run PLM_HEBB2 200 times on PLExp1 data and 200 times on PLExp2 data
%% with each of the 8 parameter sets.
%%
>> tic;sst32=NewSpdCmp32(Mpar,200);save('foo32.mat');toc, 
% Elapsed time 36 minutes on IBM 8310!!
>> tic;sst36=NewSpdCmp36(Mpar,200);save('foo36.mat');toc,
% Elapsed time 40 minutes on IBM 8310!!

%% Discard all sumstats fields except the first four:
%% N_runs, zP_congr, zP_incon, dprime, accZP
>> discard=fields(sst32);discard=discard(6:end);sst32=rmfield(sst32,discard)
>> discard=fields(sst36);discard=discard(6:end);sst36=rmfield(sst36,discard)

>> clear PLM_CACHE;save(fullfile(work_pathstr,'PLPaper2','simul','go_NewSpdCmp.mat'));


%%%%% Plot the curves for Mpar sets 1-4:  1=err='bo-',2=cor='kx-',3=all='rd-',4='no'='r.-', same stimuli, same parameters
k=1;L=sst32;tL=[1:32]';R=sst36;tR=[1:36]';l={'err','corr','all','none'};titleL='Diff fdbk modes. oN=.17, b=2.22, Wf=1.8';titleR=titleL;
figure(2);subplot(1,2,1);plot(tL,L(k).dprime,'bo-',tL,L(k+1).dprime,'kx-',tL,L(k+2).dprime,'rd-',tL,L(k+3).dprime,'r.-');axis([0 37 0 3.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('d''');title(titleL);
figure(2);subplot(1,2,2);plot(tR,R(k).dprime,'bo-',tR,R(k+1).dprime,'kx-',tR,R(k+2).dprime,'rd-',tR,R(k+3).dprime,'r.-');axis([0 37 0 3.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('d''');title(titleR);
figure(4);subplot(1,2,1);plot(tL,L(k).zP_congr,'bo-',tL,L(k+1).zP_congr,'kx-',tL,L(k+2).zP_congr,'rd-',tL,L(k+3).zP_congr,'r.-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title('Congruent stimuli, PLExp1');
figure(4);subplot(1,2,2);plot(tR,R(k).zP_congr,'bo-',tR,R(k+1).zP_congr,'kx-',tR,R(k+2).zP_congr,'rd-',tR,R(k+3).zP_congr,'r.-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title('Congruent stimuli, PLExp1');
figure(3);subplot(1,2,1);plot(tL,L(k).zP_incon,'bo-',tL,L(k+1).zP_incon,'kx-',tL,L(k+2).zP_incon,'rd-',tL,L(k+3).zP_incon,'r.-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title('Incongruent stimuli, PLExp1');
figure(3);subplot(1,2,2);plot(tR,R(k).zP_incon,'bo-',tR,R(k+1).zP_incon,'kx-',tR,R(k+2).zP_incon,'rd-',tR,R(k+3).zP_incon,'r.-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title('Incongruent stimuli, PLExp1');

figure(1);subplot(3,2,1);plot(tL,mean(L(k).dprime,2),'bo-',tL,mean(L(k+1).dprime,2),'kx-',tL,mean(L(k+2).dprime,2),'rd-',tL,mean(L(k+3).dprime,2),'r.-');axis([0 37 0 2.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('d''');title(titleL);
figure(1);subplot(3,2,2);plot(tR,mean(R(k).dprime,2),'bo-',tR,mean(R(k+1).dprime,2),'kx-',tR,mean(R(k+2).dprime,2),'rd-',tR,mean(R(k+3).dprime,2),'r.-');axis([0 37 0 2.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('d''');title(titleR);
figure(1);subplot(3,2,3);plot(tL,mean(L(k).zP_congr,2),'bo-',tL,mean(L(k+1).zP_congr,2),'kx-',tL,mean(L(k+2).zP_congr,2),'rd-',tL,mean(L(k+3).zP_congr,2),'r.-');axis([0 37 0 2.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title('Congruent stimuli, PLExp1');
figure(1);subplot(3,2,4);plot(tR,mean(R(k).zP_congr,2),'bo-',tR,mean(R(k+1).zP_congr,2),'kx-',tR,mean(R(k+2).zP_congr,2),'rd-',tR,mean(R(k+3).zP_congr,2),'r.-');axis([0 37 0 2.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title('Congruent stimuli, PLExp1');
figure(1);subplot(3,2,5);plot(tL,mean(L(k).zP_incon,2),'bo-',tL,mean(L(k+1).zP_incon,2),'kx-',tL,mean(L(k+2).zP_incon,2),'rd-',tL,mean(L(k+3).zP_incon,2),'r.-');axis([0 37 0 2.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title('Incongruent stimuli, PLExp1');legend(l{:},2);
figure(1);subplot(3,2,6);plot(tR,mean(R(k).zP_incon,2),'bo-',tR,mean(R(k+1).zP_incon,2),'kx-',tR,mean(R(k+2).zP_incon,2),'rd-',tR,mean(R(k+3).zP_incon,2),'r.-');axis([0 37 0 2.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title('Incongruent stimuli, PLExp1');legend(l{:},2);

% Figures saved as pages in PLPaper2\simul\SpdCmp_e32_oN17.pdf


%%%%% Plot the curves for Mpar sets 5-8:  1=err='bo-',2=cor='kx-',3=all='rd-',4='no'='r.-', same stimuli, same parameters
k=5;L=sst32;tL=[1:32]';R=sst36;tR=[1:36]';l={'err','corr','all','none'};titleL='Diff fdbk modes. oN=.156, b=0.95, Wf=1.8';titleR=titleL;
figure(2);subplot(1,2,1);plot(tL,L(k).dprime,'bo-',tL,L(k+1).dprime,'kx-',tL,L(k+2).dprime,'rd-',tL,L(k+3).dprime,'r.-');axis([0 37 0 3.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('d''');title(titleL);
figure(2);subplot(1,2,2);plot(tR,R(k).dprime,'bo-',tR,R(k+1).dprime,'kx-',tR,R(k+2).dprime,'rd-',tR,R(k+3).dprime,'r.-');axis([0 37 0 3.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('d''');title(titleR);
figure(4);subplot(1,2,1);plot(tL,L(k).zP_congr,'bo-',tL,L(k+1).zP_congr,'kx-',tL,L(k+2).zP_congr,'rd-',tL,L(k+3).zP_congr,'r.-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title('Congruent stimuli, PLExp2');
figure(4);subplot(1,2,2);plot(tR,R(k).zP_congr,'bo-',tR,R(k+1).zP_congr,'kx-',tR,R(k+2).zP_congr,'rd-',tR,R(k+3).zP_congr,'r.-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title('Congruent stimuli, PLExp2');
figure(3);subplot(1,2,1);plot(tL,L(k).zP_incon,'bo-',tL,L(k+1).zP_incon,'kx-',tL,L(k+2).zP_incon,'rd-',tL,L(k+3).zP_incon,'r.-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title('Incongruent stimuli, PLExp2');
figure(3);subplot(1,2,2);plot(tR,R(k).zP_incon,'bo-',tR,R(k+1).zP_incon,'kx-',tR,R(k+2).zP_incon,'rd-',tR,R(k+3).zP_incon,'r.-');axis([0 37 -1 2]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title('Incongruent stimuli, PLExp2');

figure(1);subplot(3,2,1);plot(tL,mean(L(k).dprime,2),'bo-',tL,mean(L(k+1).dprime,2),'kx-',tL,mean(L(k+2).dprime,2),'rd-',tL,mean(L(k+3).dprime,2),'r.-');axis([0 37 0 2.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('d''');title(titleL);
figure(1);subplot(3,2,2);plot(tR,mean(R(k).dprime,2),'bo-',tR,mean(R(k+1).dprime,2),'kx-',tR,mean(R(k+2).dprime,2),'rd-',tR,mean(R(k+3).dprime,2),'r.-');axis([0 37 0 2.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('d''');title(titleR);
figure(1);subplot(3,2,3);plot(tL,mean(L(k).zP_congr,2),'bo-',tL,mean(L(k+1).zP_congr,2),'kx-',tL,mean(L(k+2).zP_congr,2),'rd-',tL,mean(L(k+3).zP_congr,2),'r.-');axis([0 37 0 2.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title('Congruent stimuli, PLExp2');
figure(1);subplot(3,2,4);plot(tR,mean(R(k).zP_congr,2),'bo-',tR,mean(R(k+1).zP_congr,2),'kx-',tR,mean(R(k+2).zP_congr,2),'rd-',tR,mean(R(k+3).zP_congr,2),'r.-');axis([0 37 0 2.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title('Congruent stimuli, PLExp2');
figure(1);subplot(3,2,5);plot(tL,mean(L(k).zP_incon,2),'bo-',tL,mean(L(k+1).zP_incon,2),'kx-',tL,mean(L(k+2).zP_incon,2),'rd-',tL,mean(L(k+3).zP_incon,2),'r.-');axis([0 37 0 2.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title('Incongruent stimuli, PLExp2');legend(l{:},2);
figure(1);subplot(3,2,6);plot(tR,mean(R(k).zP_incon,2),'bo-',tR,mean(R(k+1).zP_incon,2),'kx-',tR,mean(R(k+2).zP_incon,2),'rd-',tR,mean(R(k+3).zP_incon,2),'r.-');axis([0 37 0 2.5]);set(gca,'xtick',[0:4:36]);grid on;ylabel('zPcorrect');title('Incongruent stimuli, PLExp2');legend(l{:},2);

% Figures saved as pages in PLPaper2\simul\SpdCmp_n36_par2.pdf


%%%%%  Plot Mpar(1) results against the empirical data from PLExp1
>> L=sst32(1);plot_PLM_fit({L.zP_congr',L.zP_incon'},eZfk32');
%% Figure saved as PLPaper2\simul\PLExp1fits_e32_oN17a.pdf

%%%%%  Plot Mpar(8) results against the empirical data from PLExp2
>> R=sst36(8);plot_PLM_fit2({R.zP_congr',R.zP_incon'},eZnf36');
%% Figure saved as PLPaper2\simul\PLExp2fits_n36_par2.pdf
