# Query in For loop

(I did not know how to write this properly. Excuse me for that.)

For[x = 0.1, x < 3.5, x = x + 0.1,

For[i = 1, i < 4, i++,

If[y1[[i]] != 0,
s1 = k^2 + (d - ((g1^2)*y1[[i]]/wm))^2 + 2*k*gm + wm^2;
s2 = (k^2 + (d - ((g1^2)*y1[[i]]/wm))^2)*gm + 2*k*wm^2;
s3 = (k^2 + (d - ((g1^2)*y1[[i]]/wm))^2)*(wm^2) - (d - (g1^2*
y1[[i]]/wm))*wm*(g1^2)*(2*y1[[i]]), Continue[]];


Here in place of Continue I want to go back to my inner loop ,i.e , if this If is not satisfied I want the inner for loop to run again. Thank you for the help.

there are several things wrong:

• The "Continue[]" is not needed

• You need 2 closing brackets at the end.

• y1 should be a vector with values. y[],y[], y[ are not specified

• I added two print statement in order that you can see what is going on

y1 = {1, 0, 2};

For[x = 0.1, x < 3.5, x = x + 0.1, For[i = 1, i < 4, i++,

Print["{x,i}=", {x, i}];

If[y1[[i]] != 0,
Print["inside inner loop"];
s1 = k^2 + (d - ((g1^2)*y1[[i]]/wm))^2 + 2*k*gm + wm^2;
s2 = (k^2 + (d - ((g1^2)*y1[[i]]/wm))^2)*gm + 2*k*wm^2;
s3 = (k^2 + (d - ((g1^2)*y1[[i]]/wm))^2)*(wm^2) - (d - (g1^2*
y1[[i]]/wm))*wm*(g1^2)*(2*y1[[i]])]]]