(adsbygoogle = window.adsbygoogle || []).push({}); For loop in Matlab

I have written following code in matlab but the if condition inside the for loop isn't working properly. Can anyone tell whats the possible bug??

f=1000;

T=0.001;

g=0:0.00005:5;

w=2*f*T*pi;

s=sin(g*w);

plot(g,s);

grid on;

title('SINE FN');

xlabel(' x10^-3 TIME axis(ms)');

ylabel('sin(x)');

diary off

c=0;

for i=0:0.25:5

if(sin(w.*i)==0)

c=c+1;

end

end

display(c);

counter 'c' shows the value one instead of 11..

**Physics Forums | Science Articles, Homework Help, Discussion**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Matlab question_for loop

**Physics Forums | Science Articles, Homework Help, Discussion**