function wdot33 = wdot33Calculator(today, yesterday, lastTime, version)
%wdot33calculator.m is a function to go along with the program
%MolterNetwork.m.  It circumvents the difficulty in matrix dimensions I was
%having involving the calculation of the Hebbian plasticity

% NOTE: this function might not be working quite properly.  To remedy this,
% I will code an alternative version.  For now, the user will have the
% option of using Molter's equation or Zach's equation

global Alpha R Gamma n

choice = version;
if choice == 1;
    inter1 = ones(n,n);
    inter2 = ones(n,n);
    inter3 = ones(n,n);

    yesterday = yesterday';

    inter1 = Alpha * today * yesterday;
    
    % inter1
    for iii = 1:n
        inter2(:,iii) = inter1(:,iii) - (Gamma * today);
    end
    % inter2
    
    for iii = 1:n
        inter3(iii,:) = inter2(iii,:) + yesterday;
    end
    % inter3

    wdot33 = inter3; %* ( (R - (lastTime^2)) * lastTime)

% see if the for loops can be optimized into 1 loop; look into how that
% would work.

% *********************************************************************

elseif choice == 2;
    % Initialize wdot.  THIS MODEL assumes that the weight term decreases
    % slightly if nothing happened, decreases more for the wrong way, and
    % increases significantly for the right way
    
    wdot33 = -0.01 .* ones(size(lastTime));

    % check if yesterday's time had any spikes
    % if yesterday had no spikes, no reason to continue
    if isempty(yesterday) == 1
        % No spikes yesterday, nothing to strengthen today
    elseif isempty(yesterday) ==0
        %if yesterday spiked, but today didn't, no reason to continue
        if isempty(today) == 1
            % no spikes today, nothing to strengthen today
        elseif isempty(today) == 0
            % YAY strengthen the right one, weaken the right one
            allIs = find(today >0);
            allJs = find(yesterday >0);
            for iii = 1:length(allIs)
                for jjj = 1:length(allJs)
                    wdot33(allIs(iii),allJs(jjj)) = 4;
                    wdot33(allJs(jjj),allIs(iii)) = -0.1;
                end
            end
        end
    end
end
end
        