loop basic , need help.

1 view (last 30 days)
bibhakar
bibhakar on 9 Apr 2014
Commented: bibhakar on 9 Apr 2014
Can anyone explain me the behaviour of this particular loop and its behaviour after each iteration ??
clc;
M=3;
N=3;
for jj = 1:N
if data(jj)
signal((1:M)+M*(jj-1)) = 0
% (1:M)+M*(jj-1)
end
end
  2 Comments
ES
ES on 9 Apr 2014
what is data ? what is signal? apparently, the snippet, makes some points on the signal when the value of data is 0!
bibhakar
bibhakar on 9 Apr 2014
data = round(rand(1, 1000));

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 9 Apr 2014
It is emulating a 2D matrix with M rows, setting the first N columns of it to 0. It is as if you had written
for jj = 1 : N
signal(:,jj) = 0;
end
with signal having been defined as M x something.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!