if f(a) * f(c) < 0 b = c; end
If we want to assign c to b when the condition f(a) * f(c) < 0 is true, and assign c to a when the condition is false:
if f(a) * f(c) < 0 b = c; else a = c; end
To test the condition ``n equals to 1'', we need to use two equal signs, like n == 1, not n = 1. Note that a single = is the assignment operator. The statement n = 1 would assign 1 to n instead of testing the condition. The following assigns c to b when n equals 1, and assigns c to a when n equals to 2:
if n == 1 b = c; elseif n == 2 a = c; end