- #1
heinricht
- 7
- 0
I have a problem how write the 'for' loop in mathematica:
my previous code looks like:
count=0;
flag=0;
step=100;
For i=1:1000
count=count+1;
if count>step
if flag== 0;
flag=1;
else
flag=0;
end
count=1;
end
if flag==0
p(i)=g
else
p(i)=-g
end
end
I need to rewrite this in mathematica but I do not know how.
Is it possible to write as a function, module or block?
thanks
my previous code looks like:
count=0;
flag=0;
step=100;
For i=1:1000
count=count+1;
if count>step
if flag== 0;
flag=1;
else
flag=0;
end
count=1;
end
if flag==0
p(i)=g
else
p(i)=-g
end
end
I need to rewrite this in mathematica but I do not know how.
Is it possible to write as a function, module or block?
thanks