The error message means, that in F(i), the i has its default value, which is the imagninary unit.
As Weixin Wang has mentioned already, the solution is to replace this by "F(k)".
If you get such troubles in the future, use the debugger to find the reasons. Type this in the command window:
and run your code again. When Matlab stops at the error, check the locally used variables.
By the way, omit the brute clearing header
close all; clear all; clc;
to improve the quality of your code. Is there a reason to close figures opened by other functions? This could destroy work. clear all removed not only all variables, but clears all functions from the memory also. Reloading them from the disk wastes time without any benefit.