Implementation of a saturation function in Simulink/Matlab - matlab

I am making a Simulink/Matlab control model, however, I am unsure on how to implement the following as a Simulink block:
saturation function
Where v(t) is the input of the saturation function, u_0 is a constant and u is the output.
I looked at the saturation and saturation dynamic blocks, however, I am unsure how to implement a dynamic output with a constant limit.
Thank you very much.

You can implement it using either of the blocks you mentioned (saturation and saturation dynamic).
Attached image shows how to use the Saturation Dynamic block to model your equations. Input signal v will be truncated to either +u0 or -u0 if its amplitude is larger than u0. In this implementation saturation limit u0 is constant as you requested. For a dynamic saturation limit you can drive up and lo block inputs with any other signal.

Related

How can I make gaussian noise with certain mean value in simulink?

How can I make gaussian noise with mean= 18 and variance= 0.1 in simulink? I can't use AWGN block since I'm not able to specify mean value in it.
I want to generate the below signal which is gaussian noise with mean= 18 and variance= 0.1:
Construct the model as follows. From the Library Browser select the DSP System Toolbox, then choose the Random Source block.
Now, adjust the block parameters Source type, Mean and Variance:
Construct the model by adding a Scope block as follows:
After running the model for 10 sec., you will see the generated Gaussian noise waveform by double-clicking the Scope block. You will notice the plot is not similar to the image you posted, this is how the default plot works in Simulink.
Now, to make sure it's the correct signal, send the signal to MATLAB using the To Workspace block and plot it. This is how this noise waveform is plotted in MATLAB, the same as your image.
The mean just says how much the noise is shifted so if you take a constant function of value 18 and then add a gaussian noise of variance .1 you will get what you want.
This is assuming your noise is one-dimensional:
variance = 0.1;
std_deviation = sqrt(variance);
mean = 18;
n = 1000; % number of samples
noise = std_deviation .* randn(n, 1) + mean;

Model a saturation with only lower limit in simulink

I just need a block to model a saturation that gives me zero when the input is under a certain value and the input when it's above.
Change the Threshold in the Switch block to your desired value.

AWGN BER simulation on MATLAB/Simulink does not generate the same theoretical results

The Simulink simulation is shown below:
I am attempting a simulation of a very simple system using BPSK at a rate of 10 MHz. However, I am not sure about the AWGN block values. Specifically,
On "Signal to Noise Ratio (Eb/No)", what is the "Input signal power, referenced to 1 ohm (watts)" parameter?. How can I calculate this value? When I use the default value, which is 1, I get the following curve:
Alternatively, when I am simulating using the "Variance from Mask" option and variance = 10^(-EbNo/10), I get the following result:
Clearly, they theoretical and simulated curves are not overlapping. For this plot, I am using the Monte Carlo option found in BERTool.
Two observations:
The signal power at the input of the AWGN has to be normalized to one in order to the parameter of the AWGN module to one
The receive square raised cosine has a parameter called "decimation offset". This is used for taking the perfect sampling instant.

Add White Gaussian Noise MATLAB

When we use following Matlab function
signal=awgn(signal,5,'measured')
How much SNR do we have added to original signal?
I mean the SNR is 5 dB?
How can I add 20 dB noise to signal by using this command?
Like Dan has mentioned in the comments, the second argument is used to set the value of SNR.
However, this is under the assumption that your signal has a power of 0 dBW. In case the signal power is different, you need to increase (or decrease) the value of the snr argument appropriately.

NN activation function

I need reliable substitute for sigmoid activation function. The problem with sigmoid function is that formatted output is between 0 and 1. I need activation function with output between 0 and 255. I'm training NN with backpropagation algorithm. If I will be using some other a function do I need to tweak learning algorithm ?
The most simple solution for you problem is to scale your data. Divide the outputs of your training set by 255 during training and when you are using your trained model you have to multiply the output of your neural network by 255. This way you don't have to change the gradient calculation.
You can easily achieve that by multiplying the output by 255. That will move the data from the scale of 0 to 1 to the scale of 0 to 255.
If you change the activation function, you'll definitely need to change the calculations also. The back propagation algorithm uses gradient descent approach, so you'll need to incorporate the derivative of the activation function accordingly.