
    % generate each user's sequence
    %
    x = 2 * (rand( Nsyms, Nusers) > 0.5) - 1;

    % generate the FIR filters
    %
    FIR_0 = (stdev_v/sqrt(1-alpha2)) * randn( FIR_length, Nusers, Nchips);

    FIR_save = zeros( FIR_length, Nusers, Nchips, Nsyms);

    F = FIR_0;

    for t = 1:Nsyms
      F = alpha * F + stdev_v * randn( FIR_length, Nusers, Nchips);
      FIR_save(:,:,:,t) = F;
    end

    % normalize the FIR filters
    %
    F1 = FIR_save(:,1,:,:);
    F1_norm = sum(F1(:).*F1(:));
    for u = 2:Nusers
      F = FIR_save(:,u,:,:);
      F_norm = sum(F(:).*F(:));
      scale = sqrt( (F1_norm/F_norm) * 10^((SNR(u,SNR_index)-SNR(1,SNR_index))/10) );
      FIR_save(:,u,:,:) = F * scale;
      FIR_0(:,u,:) = FIR_0(:,u,:) * scale;
    end

    % apply the FIR filters
    %
    y = zeros( Nchips, Nsyms);

    for u = 1:Nusers
      xu = [-ones(Memory,1); x(:,u)]'; % initial -1's in the channels
      for t = 1:Nsyms
        xt = xu(t+Memory:-1:t);
        for j = 1:Nchips
          y(j,t) = y(j,t) + xt * FIR_save(:,u,j,t);
        end
      end
    end

    % noise variance based on user #1
    %
    var_noise = 10^(-SNR(1,SNR_index)/10) * F1_norm/(Nsyms*Nchips);

    noise = sqrt(var_noise).*randn( Nchips, Nsyms);

    z = y + noise; % signal plus noise
