# When simulating a voltage divider using wave digital filters I get inversed polarity outputs

I'm studying wave digital filters for my bachelor's thesis and I'm finding problems in implementing a voltage divider to test my knowledge.

Here's the circuit that I'm trying to simulate and the WDF tree that I think it's valid

To simulate the circuit above I created the following matlab code

clear all

t = [0:0.1:10];
f = 10000;
fs = 100000;
n = length(t);

% Resistance of resistors (duh)
Rv = 10e3;
R1 = 10e3;
R2 = 10e3;

% Voltage input
V = sin(2*pi*f/fs*t);

% Initialize arrays
Ac = zeros(1,n);
As2 = zeros(1,n);
Br2 = zeros(1,n);
Ar2 = zeros(1,n);
Bs2 = zeros(1,n);

% Series connector port resistances
Rps1 = Rv;
Rps2 = R1;
Rps3 = R2;

% Series connector port scattering parameters
lps11 = (2*Rps1) / (Rps1 + Rps2 + Rps3);
lps12 = (2*Rps2) / (Rps1 + Rps2 + Rps3);
lps13 = (2*Rps3) / (Rps1 + Rps2 + Rps3);

% Iterates over the whole input wave
for i=2:n
%     Inputs waves to the series connector
As1 = V(i);
As2(i) = 0;
As3(i) = 0;

%     Reflectes waves to the series connector
Bs1 = As1 - lps11*(As1 + As2(i) + As3(i));
Bs2(i) = As2(i) - lps11*(As1 + As2(i) + As3(i));
Bs3(i) = As3(i) - lps11*(As1 + As2(i) + As3(i));
end

% Calculates output voltages over resistors
Vr1 = (Bs2+As2)/2;
Vr2 = (Bs3+As3)/2;

% Plot outputs
subplot(2,1,1);
plot(t,V);
subplot(2,1,2);
plot(t,Vr1);


Which gave me the following output

The first plot is the input voltage and the second is the output voltage over one of the resistors

As can be seen the magnitude of the output is the same as expected (1/3 of the input), but the signal is multiplied by -1.

Is there something fundamentally wrong that I'm doing so that even the simplest circuit can't be correctly simulated?  