필터 지우기
필터 지우기

Vector Generation Through Loop

조회 수: 1 (최근 30일)
Saleh Msaddi
Saleh Msaddi 2020년 3월 14일
댓글: Saleh Msaddi 2020년 3월 16일
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!

채택된 답변

Sriram Tadavarty
Sriram Tadavarty 2020년 3월 14일
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
Sriram Tadavarty
Sriram Tadavarty 2020년 3월 16일
You can generate ones(N,1) and have N to be large.. It is equivalent to step function
Saleh Msaddi
Saleh Msaddi 2020년 3월 16일
alright then!
thank you :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by