doubts regarding matlab programming

Status
Not open for further replies.

M.Shobana

Member level 1
Joined
Sep 13, 2011
Messages
35
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,505
hai

I want to assign values in the circular manner in matlab
for example:
for x = 1:N
data(x) = 1;
data(x+1) = 2;
data(x+2) = 3;
end

but this is not working when the value of x is equal to 2.
I want to store value in the 'data' like data(1) = 1,data(2) = 2,data(3) = 3,data(4) = 1 ,data(5) = 2 .........data(N)
If anybody knows please help me
 

Code:
for x = 1:N
   
         if rem(x,3)== 0
data(x) = 3;
data(x-1) = 2;
data(x-2) = 1;
         end
end

only works for N=multiples of 3.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…