Hello everyone.
So I'm a beginner and I am trying to generate a smooth signal w from an original signal r
a is a constant
w(k+j) = a*w(k+j-1)+(1-a)*r(k+j) for j = 1 , 2 , ... , N
How can implement this signal and store the value of every iteration to form a vector w
Thanks in advance!

 Réponse acceptée

Sriram Tadavarty
Sriram Tadavarty le 14 Mar 2020

0 votes

Hi Saleh,
This can be done through for loop. The documentation link to for loop is https://www.mathworks.com/help/matlab/ref/for.html. Please go through this to have easy going.
The code for what is asked is: (There is no intimation of k in the condition)
% Consider a random signal of length N
N = 100;
r = rand(N,1);
% Smoothing factor a
a = 10;
% Write the loop
tmp = 0;
w = zeros(N,1);
for j = 1:N
w(j) = a*tmp+ (1-a)*r(j);
tmp = w(j);
end
% The output is provided in w
w
Hope this helps.
Regards,
Sriram

3 commentaires

Saleh Msaddi
Saleh Msaddi le 16 Mar 2020
Suppose I have a step function starting from t=0 and having a value of 1
I don't want to have the sharp step function because this is generating a huge control effort; instead I'm trying to generate a smoother signal of the step function.
Sriram Tadavarty
Sriram Tadavarty le 16 Mar 2020
You can generate ones(N,1) and have N to be large.. It is equivalent to step function
Saleh Msaddi
Saleh Msaddi le 16 Mar 2020
alright then!
thank you :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by