measuring the BER for various input data rate over a custom made channel
It looks like Tb is meant to represent the period of a bit (i.e., 1 over the bit rate), but the rest of your code is very confused about the distinction between "bits of data" and "samples of signal".

For example, N seems to be the total number of bits, but you set nb = N, where nb appears to represent the number of samples per bit &mdash; this makes no sense.

The system sample rate should be an independent parameter, and the samples/bit value should be the ratio of the sample rate and the bit rate. The calculation of the modulated waveforms should only depend on the system sample rate.